mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
r=pedemont, sr=blizzard OS/2 only - store away the lastPath from the file dialog and use it if one wasn't passed in
This commit is contained in:
parent
d0e69f1616
commit
40453ad4b9
@ -147,7 +147,11 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
|
||||
if (initialDir[0]) {
|
||||
strcpy(filedlg.szFullFile, initialDir);
|
||||
strcat(filedlg.szFullFile, "\\");
|
||||
} else if (lastPath[0]) {
|
||||
strcpy(filedlg.szFullFile, lastPath);
|
||||
strcat(filedlg.szFullFile, "\\");
|
||||
}
|
||||
|
||||
strcat(filedlg.szFullFile, fileBuffer);
|
||||
|
||||
int i;
|
||||
@ -232,11 +236,12 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
|
||||
result = PR_TRUE;
|
||||
mFile.Append(filedlg.szFullFile);
|
||||
|
||||
char* temp = (char*)gWidgetModuleData->DBCSstrrchr(filedlg.szFullFile, '\\');
|
||||
*temp = '\0';
|
||||
strcpy(lastPath, filedlg.szFullFile);
|
||||
|
||||
// Store the current directory in mDisplayDirectory
|
||||
char* newCurrentDirectory = NS_STATIC_CAST( char*, nsMemory::Alloc( MAX_PATH+1 ) );
|
||||
VERIFY(gWidgetModuleData->GetCurrentDirectory(MAX_PATH, newCurrentDirectory) > 0);
|
||||
mDisplayDirectory->InitWithPath(newCurrentDirectory);
|
||||
nsMemory::Free( newCurrentDirectory );
|
||||
mDisplayDirectory->InitWithPath(filedlg.szFullFile);
|
||||
mSelectedType = (PRInt16)pmydata->ulCurExt;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "nsdefs.h"
|
||||
#include "nsIFileChannel.h"
|
||||
|
||||
static char lastPath[CCHMAXPATH] = { 0 };
|
||||
|
||||
/**
|
||||
* Native Windows FileSelector wrapper
|
||||
*/
|
||||
|
@ -453,42 +453,6 @@ HWND nsWidgetModuleData::GetWindowForPrinting( PCSZ pszClass, ULONG ulStyle)
|
||||
|
||||
#endif
|
||||
|
||||
ULONG nsWidgetModuleData::GetCurrentDirectory(ULONG bufLen, PSZ dirString)
|
||||
{
|
||||
ULONG drivemap,currentdisk;
|
||||
const char * strPtr = dirString +3;
|
||||
|
||||
// We need extra space for the 'x:\'.
|
||||
if (bufLen < 3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ULONG len = bufLen - 3;
|
||||
|
||||
APIRET rc = DosQueryCurrentDir(0, (PBYTE)strPtr, &len);
|
||||
if (rc != ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
if (rc)
|
||||
return 0;
|
||||
len = strlen(strPtr) + 3;
|
||||
|
||||
// Directory does not start with 'x:\', so add it.
|
||||
DosQueryCurrentDisk (¤tdisk, &drivemap);
|
||||
|
||||
// Follow the case of the first letter in the path.
|
||||
if (isupper(dirString[3]))
|
||||
dirString[0] = (char)('A' - 1 + currentdisk);
|
||||
else
|
||||
dirString[0] = (char)('a' - 1 + currentdisk);
|
||||
dirString[1] = ':';
|
||||
dirString[2] = '\\';
|
||||
}
|
||||
else
|
||||
len += 3; // Add three extra spaces for the 'x:\'.
|
||||
return len;
|
||||
}
|
||||
|
||||
int nsWidgetModuleData::WideCharToMultiByte( int CodePage, const PRUnichar *pText, ULONG ulLength, char* szBuffer, ULONG ulSize )
|
||||
{
|
||||
UconvObject* pConverter = 0;
|
||||
@ -532,4 +496,30 @@ int nsWidgetModuleData::WideCharToMultiByte( int CodePage, const PRUnichar *pTex
|
||||
return ulSize - cplen;
|
||||
}
|
||||
|
||||
const char *nsWidgetModuleData::DBCSstrchr( const char *string, int c )
|
||||
{
|
||||
const char* p = string;
|
||||
do {
|
||||
if (*p == c)
|
||||
break;
|
||||
p = WinNextChar(0,0,0,(char*)p);
|
||||
} while (*p); /* enddo */
|
||||
// Result is p or NULL
|
||||
return *p ? p : (char*)NULL;
|
||||
}
|
||||
|
||||
|
||||
const char *nsWidgetModuleData::DBCSstrrchr( const char *string, int c )
|
||||
{
|
||||
int length = strlen(string);
|
||||
const char* p = string+length;
|
||||
do {
|
||||
if (*p == c)
|
||||
break;
|
||||
p = WinPrevChar(0,0,0,(char*)string,(char*)p);
|
||||
} while (p > string); /* enddo */
|
||||
// Result is p or NULL
|
||||
return (*p == c) ? p : (char*)NULL;
|
||||
}
|
||||
|
||||
nsWidgetModuleData *gWidgetModuleData = nsnull;
|
||||
|
@ -79,9 +79,9 @@ class nsWidgetModuleData : public nsISupports
|
||||
ATOM GetAtom( const char *atomname);
|
||||
ATOM GetAtom( const nsString &atomname);
|
||||
|
||||
ULONG GetCurrentDirectory(ULONG bufLen, PSZ dirString);
|
||||
|
||||
int WideCharToMultiByte( int CodePage, const PRUnichar *pText, ULONG ulLength, char* szBuffer, ULONG ulSize );
|
||||
const char *DBCSstrchr( const char *string, int c );
|
||||
const char *DBCSstrrchr( const char *string, int c );
|
||||
|
||||
#if 0
|
||||
HWND GetWindowForPrinting( PCSZ pszClass, ULONG ulStyle);
|
||||
|
Loading…
Reference in New Issue
Block a user