Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsFileSelector Class Reference

#include <nsFileSelector.h>

List of all members.

Public Member Functions

 nsFileSelector ()
 ~nsFileSelector ()
OSErr SelectFile (FSSpecPtr aOutFile)
OSErr SelectFolder (FSSpecPtr aOutFolder)

Private Member Functions

OSErr GetCWD (long *aOutDirID, short *aOutVRefNum)

Private Attributes

FSSpecPtr mFile

Detailed Description

Definition at line 46 of file nsFileSelector.h.


Constructor & Destructor Documentation

Definition at line 47 of file nsFileSelector.cpp.

{
       mFile = NULL;
}

Definition at line 52 of file nsFileSelector.cpp.

{

}

Member Function Documentation

OSErr nsFileSelector::GetCWD ( long aOutDirID,
short *  aOutVRefNum 
) [private]

Definition at line 171 of file nsFileSelector.cpp.

{
       OSErr                       err = noErr;
       ProcessSerialNumber  psn;
       ProcessInfoRec              pInfo;
       FSSpec                      tmp;
       
       /* get cwd based on curr ps info */
       if (!(err = GetCurrentProcess(&psn))) 
       {
              pInfo.processName = nil;
              pInfo.processAppSpec = &tmp;
              pInfo.processInfoLength = (sizeof(ProcessInfoRec));
              
              if(!(err = GetProcessInformation(&psn, &pInfo)))
              {
                     *aOutDirID = pInfo.processAppSpec->parID;
                     *aOutVRefNum = pInfo.processAppSpec->vRefNum;
              }
       }
       
       return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 83 of file nsFileSelector.cpp.

{
       OSErr  err = noErr;
       NavReplyRecord              reply; 
       NavDialogOptions     dlgOpts;
       NavEventUPP                 eventProc;
       AEDesc                      resultDesc, initDesc;
       FSSpec                      tmp;
       short                       cwdVRefNum;
       long                        cwdDirID, len;
       
       mFile = aOutFile;
       
       err = NavGetDefaultDialogOptions(&dlgOpts);
       len = strlen("Please select a file");
       nsAppleSingleDecoder::PLstrncpy(dlgOpts.message, "\pPlease select a file", len);
       eventProc = NewNavEventProc( (ProcPtr) OurNavEventFunction );
       
       ERR_CHECK( GetCWD(&cwdDirID, &cwdVRefNum) );
       ERR_CHECK( FSMakeFSSpec(cwdVRefNum, cwdDirID, NULL, &tmp) );
       ERR_CHECK( AECreateDesc(typeFSS, (void*) &tmp, sizeof(FSSpec), &initDesc) );
       
       err = NavChooseFile( &initDesc, &reply, &dlgOpts, eventProc, NULL, NULL, NULL, NULL );     
              
       AEDisposeDesc(&initDesc);
       DisposeRoutineDescriptor(eventProc);
              
       if((reply.validRecord) && (err == noErr))
       {
              if((err = AECoerceDesc(&(reply.selection),typeFSS,&resultDesc)) == noErr)
              {
                     BlockMoveData(*resultDesc.dataHandle,&tmp,sizeof(FSSpec));
                     /* forces name to get filled */
                     FSMakeFSSpec(tmp.vRefNum, tmp.parID, tmp.name, aOutFile); 
              }
            
              AEDisposeDesc(&resultDesc);
              NavDisposeReply(&reply);
       }
       
       return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSErr nsFileSelector::SelectFolder ( FSSpecPtr  aOutFolder)

Definition at line 127 of file nsFileSelector.cpp.

{
       OSErr  err = noErr;
       NavReplyRecord              reply; 
       NavDialogOptions     dlgOpts;
       NavEventUPP                 eventProc;
       AEDesc                      resultDesc, initDesc;
       FSSpec                      tmp;
       short                       cwdVRefNum;
       long                        cwdDirID, len;
       
       mFile = aOutFolder;
       
       err = NavGetDefaultDialogOptions(&dlgOpts);
       len = strlen("Please select a folder");
       nsAppleSingleDecoder::PLstrncpy(dlgOpts.message, "\pPlease select a folder", len);
       eventProc = NewNavEventProc( (ProcPtr) OurNavEventFunction );
       
       ERR_CHECK( GetCWD(&cwdDirID, &cwdVRefNum) );
       ERR_CHECK( FSMakeFSSpec(cwdVRefNum, cwdDirID, NULL, &tmp) );
       ERR_CHECK( AECreateDesc(typeFSS, (void*) &tmp, sizeof(FSSpec), &initDesc) );
       
       err = NavChooseFolder( &initDesc, &reply, &dlgOpts, eventProc, NULL, NULL );
              
       AEDisposeDesc(&initDesc);
       DisposeRoutineDescriptor(eventProc);
              
       if((reply.validRecord) && (err == noErr))
       {
              if((err = AECoerceDesc(&(reply.selection),typeFSS,&resultDesc)) == noErr)
              {
                     BlockMoveData(*resultDesc.dataHandle,&tmp,sizeof(FSSpec));
                     /* forces name to get filled */
                     FSMakeFSSpec(tmp.vRefNum, tmp.parID, tmp.name, aOutFolder); 
              }
            
              AEDisposeDesc(&resultDesc);
              NavDisposeReply(&reply);
       }
       
       return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 59 of file nsFileSelector.h.


The documentation for this class was generated from the following files: