wxFindFirst/NextFile() now return wxString and not "char *", wxGetCwd() added
(to be used instead of wxGetWorkingDirectory) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1656 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -107,6 +107,12 @@ TRUE if successful.
|
||||
|
||||
Copies {\it file1} to {\it file2}, returning TRUE if successful.
|
||||
|
||||
\membersection{::wxGetCwd}\label{wxgetcwd}
|
||||
|
||||
\func{wxString}{wxGetCwd}{\void}
|
||||
|
||||
Returns a string containing the current (or working) directory.
|
||||
|
||||
\membersection{::wxGetHostName}\label{wxgethostname}
|
||||
|
||||
\func{bool}{wxGetHostName}{\param{const wxString\& }{buf}, \param{int }{sz}}
|
||||
@@ -158,6 +164,8 @@ Returns TRUE if successful, FALSE otherwise.
|
||||
|
||||
\func{wxString}{wxGetWorkingDirectory}{\param{const wxString\& }{buf=NULL}, \param{int }{sz=1000}}
|
||||
|
||||
This function is obsolete: use \helpref{wxGetCwd}{wxgetcwd} instead.
|
||||
|
||||
Copies the current working directory into the buffer if supplied, or
|
||||
copies the working directory into new storage (which you must delete yourself)
|
||||
if the buffer is NULL.
|
||||
|
@@ -39,11 +39,12 @@ typedef long off_t;
|
||||
|
||||
const off_t wxInvalidOffset = (off_t)-1;
|
||||
|
||||
typedef enum {
|
||||
enum wxSeekMode
|
||||
{
|
||||
wxFromStart,
|
||||
wxFromCurrent,
|
||||
wxFromEnd
|
||||
} wxSeekMode;
|
||||
};
|
||||
|
||||
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
|
||||
|
||||
@@ -68,7 +69,6 @@ WXDLLEXPORT wxString wxFileNameFromPath(const wxString& path);
|
||||
#define FileNameFromPath wxFileNameFromPath
|
||||
|
||||
// Get directory
|
||||
WXDLLEXPORT char* wxPathOnly(char *path);
|
||||
WXDLLEXPORT wxString wxPathOnly(const wxString& path);
|
||||
#define PathOnly wxPathOnly
|
||||
|
||||
@@ -86,6 +86,7 @@ WXDLLEXPORT void wxUnix2DosFilename(char *s);
|
||||
WXDLLEXPORT void wxMac2UnixFilename(char *s);
|
||||
WXDLLEXPORT void wxUnix2MacFilename(char *s);
|
||||
#endif
|
||||
|
||||
// Strip the extension, in situ
|
||||
WXDLLEXPORT void wxStripExtension(char *buffer);
|
||||
WXDLLEXPORT void wxStripExtension(wxString& buffer);
|
||||
@@ -113,8 +114,8 @@ WXDLLEXPORT char* wxCopyAbsolutePath(const wxString& path);
|
||||
// Flags are reserved for future use.
|
||||
#define wxFILE 1
|
||||
#define wxDIR 2
|
||||
WXDLLEXPORT char* wxFindFirstFile(const char *spec, int flags = wxFILE);
|
||||
WXDLLEXPORT char* wxFindNextFile(void);
|
||||
WXDLLEXPORT wxString wxFindFirstFile(const char *spec, int flags = wxFILE);
|
||||
WXDLLEXPORT wxString wxFindNextFile();
|
||||
|
||||
// Does the pattern contain wildcards?
|
||||
WXDLLEXPORT bool wxIsWild(const wxString& pattern);
|
||||
@@ -142,6 +143,9 @@ WXDLLEXPORT bool wxRenameFile(const wxString& file1, const wxString& file2);
|
||||
// IMPORTANT NOTE getcwd is know not to work under some releases
|
||||
// of Win32s 1.3, according to MS release notes!
|
||||
WXDLLEXPORT char* wxGetWorkingDirectory(char *buf = (char *) NULL, int sz = 1000);
|
||||
// new and preferred version of wxGetWorkingDirectory
|
||||
// NB: can't have the same name because of overloading ambiguity
|
||||
WXDLLEXPORT wxString wxGetCwd();
|
||||
|
||||
// Set working directory
|
||||
WXDLLEXPORT bool wxSetWorkingDirectory(const wxString& d);
|
||||
@@ -153,23 +157,23 @@ WXDLLEXPORT bool wxMkdir(const wxString& dir);
|
||||
WXDLLEXPORT bool wxRmdir(const wxString& dir, int flags = 0);
|
||||
|
||||
// separators in file names
|
||||
#define FILE_SEP_EXT '.'
|
||||
#define FILE_SEP_DSK ':'
|
||||
#define FILE_SEP_PATH_DOS '\\'
|
||||
#define FILE_SEP_PATH_UNIX '/'
|
||||
#define wxFILE_SEP_EXT '.'
|
||||
#define wxFILE_SEP_DSK ':'
|
||||
#define wxFILE_SEP_PATH_DOS '\\'
|
||||
#define wxFILE_SEP_PATH_UNIX '/'
|
||||
|
||||
// separator in the path list (as in PATH environment variable)
|
||||
// NB: these are strings and not characters on purpose!
|
||||
#define PATH_SEP_DOS ";"
|
||||
#define PATH_SEP_UNIX ":"
|
||||
#define wxPATH_SEP_DOS ";"
|
||||
#define wxPATH_SEP_UNIX ":"
|
||||
|
||||
// platform independent versions
|
||||
#ifdef __UNIX__
|
||||
#define FILE_SEP_PATH FILE_SEP_PATH_UNIX
|
||||
#define PATH_SEP PATH_SEP_UNIX
|
||||
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_UNIX
|
||||
#define wxPATH_SEP wxPATH_SEP_UNIX
|
||||
#else // Windows
|
||||
#define FILE_SEP_PATH FILE_SEP_PATH_DOS
|
||||
#define PATH_SEP PATH_SEP_DOS
|
||||
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS
|
||||
#define wxPATH_SEP wxPATH_SEP_DOS
|
||||
#endif // Unix/Windows
|
||||
|
||||
// this is useful for wxString::IsSameAs(): to compare two file names use
|
||||
@@ -182,7 +186,7 @@ WXDLLEXPORT bool wxRmdir(const wxString& dir, int flags = 0);
|
||||
|
||||
// is the char a path separator?
|
||||
inline bool wxIsPathSeparator(char c)
|
||||
{ return c == FILE_SEP_PATH_DOS || c == FILE_SEP_PATH_UNIX; }
|
||||
{ return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX; }
|
||||
|
||||
// does the string ends with path separator?
|
||||
WXDLLEXPORT bool wxEndsWithPathSeparator(const char *pszFileName);
|
||||
@@ -209,19 +213,20 @@ WXDLLEXPORT wxString wxGetOSDirectory();
|
||||
class WXDLLEXPORT wxPathList : public wxStringList
|
||||
{
|
||||
public:
|
||||
void AddEnvList(const wxString& envVariable); // Adds all paths in environment variable
|
||||
// Adds all paths in environment variable
|
||||
void AddEnvList(const wxString& envVariable);
|
||||
|
||||
void Add(const wxString& path);
|
||||
// Avoid compiler warning
|
||||
wxNode *Add(const char *s) { return wxStringList::Add(s); }
|
||||
|
||||
wxString FindValidPath(const wxString& filename); // Find the first full path
|
||||
// for which the file exists
|
||||
wxString FindAbsoluteValidPath(const wxString& filename); // Find the first full path
|
||||
// for which the file exists; ensure it's an absolute
|
||||
// path that gets returned.
|
||||
void EnsureFileAccessible(const wxString& path); // Given full path and filename,
|
||||
// add path to list
|
||||
// Find the first full path for which the file exists
|
||||
wxString FindValidPath(const wxString& filename);
|
||||
// Find the first full path for which the file exists; ensure it's an
|
||||
// absolute path that gets returned.
|
||||
wxString FindAbsoluteValidPath(const wxString& filename);
|
||||
// Given full path and filename, add path to list
|
||||
void EnsureFileAccessible(const wxString& path);
|
||||
// Returns TRUE if the path is in the list
|
||||
bool Member(const wxString& path);
|
||||
|
||||
private:
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__)
|
||||
#include <direct.h>
|
||||
#include <dos.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif // __WINDOWS__
|
||||
#endif // native Win compiler
|
||||
|
||||
#ifdef __GNUWIN32__
|
||||
#ifndef __TWIN32__
|
||||
@@ -148,12 +148,11 @@ void wxPathList::AddEnvList (const wxString& envVariable)
|
||||
// to the list if not already there.
|
||||
void wxPathList::EnsureFileAccessible (const wxString& path)
|
||||
{
|
||||
wxString path1(path);
|
||||
char *path_only = wxPathOnly (WXSTRINGCAST path1);
|
||||
if (path_only)
|
||||
wxString path_only(wxPathOnly(path));
|
||||
if ( !path_only.IsEmpty() )
|
||||
{
|
||||
if (!Member (wxString(path_only)))
|
||||
Add (wxString(path_only));
|
||||
if ( !Member(path_only) )
|
||||
Add(path_only);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +390,7 @@ char *wxCopyAbsolutePath(const wxString& filename)
|
||||
if (! IsAbsolutePath(wxExpandPath(wxBuffer, filename))) {
|
||||
char buf[_MAXPATHLEN];
|
||||
buf[0] = '\0';
|
||||
wxGetWorkingDirectory(buf, sizeof(buf)/sizeof(char));
|
||||
wxGetWorkingDirectory(buf, WXSIZEOF(buf));
|
||||
char ch = buf[strlen(buf) - 1];
|
||||
#ifdef __WXMSW__
|
||||
if (ch != '\\' && ch != '/')
|
||||
@@ -1135,268 +1134,280 @@ char *wxGetTempFileName(const wxString& prefix, char *buf)
|
||||
// Flags are reserved for future use.
|
||||
|
||||
#ifndef __VMS__
|
||||
static DIR *wxDirStream = (DIR *) NULL;
|
||||
static char *wxFileSpec = (char *) NULL;
|
||||
static int wxFindFileFlags = 0;
|
||||
static DIR *gs_dirStream = (DIR *) NULL;
|
||||
static wxString gs_strFileSpec;
|
||||
static int gs_findFlags = 0;
|
||||
#endif
|
||||
|
||||
char *wxFindFirstFile(const char *spec, int flags)
|
||||
wxString wxFindFirstFile(const char *spec, int flags)
|
||||
{
|
||||
wxString result;
|
||||
|
||||
#ifndef __VMS__
|
||||
if (wxDirStream)
|
||||
closedir(wxDirStream); // edz 941103: better housekeping
|
||||
if (gs_dirStream)
|
||||
closedir(gs_dirStream); // edz 941103: better housekeping
|
||||
|
||||
wxFindFileFlags = flags;
|
||||
gs_findFlags = flags;
|
||||
|
||||
if (wxFileSpec)
|
||||
delete[] wxFileSpec;
|
||||
wxFileSpec = copystring(spec);
|
||||
gs_strFileSpec = spec;
|
||||
|
||||
// Find path only so we can concatenate
|
||||
// found file onto path
|
||||
char *p = wxPathOnly(wxFileSpec);
|
||||
wxString path(wxPathOnly(gs_strFileSpec));
|
||||
|
||||
/* MATTHEW: special case: path is really "/" */
|
||||
if (p && !*p && *wxFileSpec == '/')
|
||||
p = "/";
|
||||
/* MATTHEW: p is NULL => Local directory */
|
||||
if (!p)
|
||||
p = ".";
|
||||
// special case: path is really "/"
|
||||
if ( !path && gs_strFileSpec[0u] == '/' )
|
||||
path = '/';
|
||||
// path is empty => Local directory
|
||||
if ( !path )
|
||||
path = '.';
|
||||
|
||||
if ((wxDirStream=opendir(p))==NULL)
|
||||
return (char *) NULL;
|
||||
gs_dirStream = opendir(path);
|
||||
if ( !gs_dirStream )
|
||||
{
|
||||
wxLogSysError(_("Can not enumerate files in directory '%s'"),
|
||||
path.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = wxFindNextFile();
|
||||
}
|
||||
#endif // !VMS
|
||||
|
||||
/* MATTHEW: [5] wxFindNextFile can do the rest of the work */
|
||||
return wxFindNextFile();
|
||||
#endif
|
||||
// ifndef __VMS__
|
||||
return (char *) NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
char *wxFindNextFile(void)
|
||||
wxString wxFindNextFile()
|
||||
{
|
||||
#ifndef __VMS__
|
||||
static char buf[400]; // FIXME static buffer
|
||||
wxString result;
|
||||
|
||||
/* MATTHEW: [2] Don't crash if we read too many times */
|
||||
if (!wxDirStream)
|
||||
return (char *) NULL;
|
||||
#ifndef __VMS__
|
||||
wxCHECK_MSG( gs_dirStream, result, "must call wxFindFirstFile first" );
|
||||
|
||||
// Find path only so we can concatenate
|
||||
// found file onto path
|
||||
char *p = wxPathOnly(wxFileSpec);
|
||||
char *n = wxFileNameFromPath(wxFileSpec);
|
||||
wxString path(wxPathOnly(gs_strFileSpec));
|
||||
wxString name(wxFileNameFromPath(gs_strFileSpec));
|
||||
|
||||
/* MATTHEW: special case: path is really "/" */
|
||||
if (p && !*p && *wxFileSpec == '/')
|
||||
p = "/";
|
||||
if ( !path && gs_strFileSpec[0u] == '/')
|
||||
path = '/';
|
||||
|
||||
// Do the reading
|
||||
struct dirent *nextDir;
|
||||
for (nextDir = readdir(wxDirStream); nextDir != NULL; nextDir = readdir(wxDirStream))
|
||||
for ( nextDir = readdir(gs_dirStream);
|
||||
nextDir != NULL;
|
||||
nextDir = readdir(gs_dirStream) )
|
||||
{
|
||||
if (wxMatchWild(name, nextDir->d_name))
|
||||
{
|
||||
result.Empty();
|
||||
if ( !path.IsEmpty() )
|
||||
{
|
||||
result = path;
|
||||
if ( path != '/' )
|
||||
result += '/';
|
||||
}
|
||||
|
||||
/* MATTHEW: [5] Only return "." and ".." when they match, and only return
|
||||
directories when flags & wxDIR */
|
||||
if (wxMatchWild(n, nextDir->d_name)) {
|
||||
result += nextDir->d_name;
|
||||
|
||||
// Only return "." and ".." when they match
|
||||
bool isdir;
|
||||
|
||||
buf[0] = 0;
|
||||
if (p && *p) {
|
||||
strcpy(buf, p);
|
||||
if (strcmp(p, "/") != 0)
|
||||
strcat(buf, "/");
|
||||
}
|
||||
strcat(buf, nextDir->d_name);
|
||||
|
||||
if ( (strcmp(nextDir->d_name, ".") == 0) ||
|
||||
(strcmp(nextDir->d_name, "..") == 0)) {
|
||||
if (wxFindFileFlags && !(wxFindFileFlags & wxDIR))
|
||||
continue;
|
||||
(strcmp(nextDir->d_name, "..") == 0))
|
||||
{
|
||||
if ( (gs_findFlags & wxDIR) != 0 )
|
||||
isdir = TRUE;
|
||||
} else
|
||||
isdir = wxDirExists(buf);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
isdir = wxDirExists(result);
|
||||
|
||||
if (!wxFindFileFlags
|
||||
|| ((wxFindFileFlags & wxDIR) && isdir)
|
||||
|| ((wxFindFileFlags & wxFILE) && !isdir))
|
||||
return buf;
|
||||
// and only return directories when flags & wxDIR
|
||||
if ( !gs_findFlags ||
|
||||
((gs_findFlags & wxDIR) && isdir) ||
|
||||
((gs_findFlags & wxFILE) && !isdir) )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(wxDirStream);
|
||||
wxDirStream = (DIR *) NULL;
|
||||
#endif
|
||||
// ifndef __VMS__
|
||||
|
||||
return (char *) NULL;
|
||||
result.Empty(); // not found
|
||||
|
||||
closedir(gs_dirStream);
|
||||
gs_dirStream = (DIR *) NULL;
|
||||
#endif // !VMS
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#elif defined(__WXMSW__)
|
||||
|
||||
#ifdef __WIN32__
|
||||
HANDLE wxFileStrucHandle = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATA wxFileStruc;
|
||||
#else
|
||||
static HANDLE gs_hFileStruct = INVALID_HANDLE_VALUE;
|
||||
static WIN32_FIND_DATA gs_findDataStruct;
|
||||
#else // Win16
|
||||
#ifdef __BORLANDC__
|
||||
static struct ffblk wxFileStruc;
|
||||
static struct ffblk gs_findDataStruct;
|
||||
#else
|
||||
static struct _find_t wxFileStruc;
|
||||
#endif
|
||||
#endif
|
||||
static wxString wxFileSpec = "";
|
||||
static int wxFindFileFlags;
|
||||
static struct _find_t gs_findDataStruct;
|
||||
#endif // Borland
|
||||
#endif // Win32/16
|
||||
|
||||
char *wxFindFirstFile(const char *spec, int flags)
|
||||
static wxString gs_strFileSpec;
|
||||
static int gs_findFlags = 0;
|
||||
|
||||
wxString wxFindFirstFile(const char *spec, int flags)
|
||||
{
|
||||
wxFileSpec = spec;
|
||||
wxFindFileFlags = flags; /* MATTHEW: [5] Remember flags */
|
||||
wxString result;
|
||||
|
||||
// Find path only so we can concatenate
|
||||
// found file onto path
|
||||
wxString path1(wxFileSpec);
|
||||
char *p = wxPathOnly(WXSTRINGCAST path1);
|
||||
if (p && (strlen(p) > 0))
|
||||
strcpy(wxBuffer, p);
|
||||
else
|
||||
wxBuffer[0] = 0;
|
||||
gs_strFileSpec = spec;
|
||||
gs_findFlags = flags; /* MATTHEW: [5] Remember flags */
|
||||
|
||||
// Find path only so we can concatenate found file onto path
|
||||
wxString path(wxPathOnly(gs_strFileSpec));
|
||||
if ( !path.IsEmpty() )
|
||||
result << path << '\\';
|
||||
|
||||
#ifdef __WIN32__
|
||||
if (wxFileStrucHandle != INVALID_HANDLE_VALUE)
|
||||
FindClose(wxFileStrucHandle);
|
||||
if ( gs_hFileStruct != INVALID_HANDLE_VALUE )
|
||||
FindClose(gs_hFileStruct);
|
||||
|
||||
wxFileStrucHandle = ::FindFirstFile(WXSTRINGCAST spec, &wxFileStruc);
|
||||
gs_hFileStruct = ::FindFirstFile(WXSTRINGCAST spec, &gs_findDataStruct);
|
||||
|
||||
if (wxFileStrucHandle == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
if ( gs_hFileStruct == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
wxLogSysError(_("Can not enumerate files in directory '%s'"),
|
||||
path.c_str());
|
||||
|
||||
bool isdir = !!(wxFileStruc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
result.Empty();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isdir = !!(gs_findDataStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
|
||||
if (isdir && !(flags & wxDIR))
|
||||
return wxFindNextFile();
|
||||
else if (!isdir && flags && !(flags & wxFILE))
|
||||
return wxFindNextFile();
|
||||
|
||||
if (wxBuffer[0] != 0)
|
||||
strcat(wxBuffer, "\\");
|
||||
strcat(wxBuffer, wxFileStruc.cFileName);
|
||||
return wxBuffer;
|
||||
#else
|
||||
result += gs_findDataStruct.cFileName;
|
||||
|
||||
return result;
|
||||
#else
|
||||
int flag = _A_NORMAL;
|
||||
if (flags & wxDIR) /* MATTHEW: [5] Use & */
|
||||
flag = _A_SUBDIR;
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
if (findfirst(WXSTRINGCAST spec, &wxFileStruc, flag) == 0)
|
||||
if (findfirst(WXSTRINGCAST spec, &gs_findDataStruct, flag) == 0)
|
||||
#else
|
||||
if (_dos_findfirst(WXSTRINGCAST spec, flag, &wxFileStruc) == 0)
|
||||
if (_dos_findfirst(WXSTRINGCAST spec, flag, &gs_findDataStruct) == 0)
|
||||
#endif
|
||||
{
|
||||
/* MATTHEW: [5] Check directory flag */
|
||||
char attrib;
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
attrib = wxFileStruc.ff_attrib;
|
||||
attrib = gs_findDataStruct.ff_attrib;
|
||||
#else
|
||||
attrib = wxFileStruc.attrib;
|
||||
attrib = gs_findDataStruct.attrib;
|
||||
#endif
|
||||
|
||||
if (attrib & _A_SUBDIR) {
|
||||
if (!(wxFindFileFlags & wxDIR))
|
||||
if (!(gs_findFlags & wxDIR))
|
||||
return wxFindNextFile();
|
||||
} else if (wxFindFileFlags && !(wxFindFileFlags & wxFILE))
|
||||
} else if (gs_findFlags && !(gs_findFlags & wxFILE))
|
||||
return wxFindNextFile();
|
||||
|
||||
if (wxBuffer[0] != 0)
|
||||
strcat(wxBuffer, "\\");
|
||||
|
||||
result +=
|
||||
#ifdef __BORLANDC__
|
||||
strcat(wxBuffer, wxFileStruc.ff_name);
|
||||
gs_findDataStruct.ff_name
|
||||
#else
|
||||
strcat(wxBuffer, wxFileStruc.name);
|
||||
gs_findDataStruct.name
|
||||
#endif
|
||||
return wxBuffer;
|
||||
;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
#endif // __WIN32__
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char *wxFindNextFile(void)
|
||||
wxString wxFindNextFile()
|
||||
{
|
||||
// Find path only so we can concatenate
|
||||
// found file onto path
|
||||
wxString p2(wxFileSpec);
|
||||
char *p = wxPathOnly(WXSTRINGCAST p2);
|
||||
if (p && (strlen(p) > 0))
|
||||
strcpy(wxBuffer, p);
|
||||
else
|
||||
wxBuffer[0] = 0;
|
||||
wxString result;
|
||||
|
||||
// Find path only so we can concatenate found file onto path
|
||||
wxString path(wxPathOnly(gs_strFileSpec));
|
||||
|
||||
try_again:
|
||||
|
||||
#ifdef __WIN32__
|
||||
if (wxFileStrucHandle == INVALID_HANDLE_VALUE)
|
||||
if (gs_hFileStruct == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
bool success = (FindNextFile(wxFileStrucHandle, &wxFileStruc) != 0);
|
||||
if (!success) {
|
||||
FindClose(wxFileStrucHandle);
|
||||
wxFileStrucHandle = INVALID_HANDLE_VALUE;
|
||||
return NULL;
|
||||
bool success = (FindNextFile(gs_hFileStruct, &gs_findDataStruct) != 0);
|
||||
if (!success)
|
||||
{
|
||||
FindClose(gs_hFileStruct);
|
||||
gs_hFileStruct = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isdir = !!(gs_findDataStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
|
||||
if (isdir && !(gs_findFlags & wxDIR))
|
||||
goto try_again;
|
||||
else if (!isdir && gs_findFlags && !(gs_findFlags & wxFILE))
|
||||
goto try_again;
|
||||
|
||||
if ( !path.IsEmpty() )
|
||||
result << path << '\\';
|
||||
result << gs_findDataStruct.cFileName;
|
||||
}
|
||||
|
||||
bool isdir = !!(wxFileStruc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
|
||||
if (isdir && !(wxFindFileFlags & wxDIR))
|
||||
goto try_again;
|
||||
else if (!isdir && wxFindFileFlags && !(wxFindFileFlags & wxFILE))
|
||||
goto try_again;
|
||||
|
||||
if (wxBuffer[0] != 0)
|
||||
strcat(wxBuffer, "\\");
|
||||
strcat(wxBuffer, wxFileStruc.cFileName);
|
||||
return wxBuffer;
|
||||
#else
|
||||
return result;
|
||||
#else // Win16
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
if (findnext(&wxFileStruc) == 0)
|
||||
if (findnext(&gs_findDataStruct) == 0)
|
||||
#else
|
||||
if (_dos_findnext(&wxFileStruc) == 0)
|
||||
if (_dos_findnext(&gs_findDataStruct) == 0)
|
||||
#endif
|
||||
{
|
||||
/* MATTHEW: [5] Check directory flag */
|
||||
char attrib;
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
attrib = wxFileStruc.ff_attrib;
|
||||
attrib = gs_findDataStruct.ff_attrib;
|
||||
#else
|
||||
attrib = wxFileStruc.attrib;
|
||||
attrib = gs_findDataStruct.attrib;
|
||||
#endif
|
||||
|
||||
if (attrib & _A_SUBDIR) {
|
||||
if (!(wxFindFileFlags & wxDIR))
|
||||
if (!(gs_findFlags & wxDIR))
|
||||
goto try_again;
|
||||
} else if (wxFindFileFlags && !(wxFindFileFlags & wxFILE))
|
||||
} else if (gs_findFlags && !(gs_findFlags & wxFILE))
|
||||
goto try_again;
|
||||
|
||||
|
||||
if (wxBuffer[0] != 0)
|
||||
strcat(wxBuffer, "\\");
|
||||
result +=
|
||||
#ifdef __BORLANDC__
|
||||
strcat(wxBuffer, wxFileStruc.ff_name);
|
||||
gs_findDataStruct.ff_name
|
||||
#else
|
||||
strcat(wxBuffer, wxFileStruc.name);
|
||||
gs_findDataStruct.name
|
||||
#endif
|
||||
return wxBuffer;
|
||||
;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
#endif
|
||||
#endif // Win32/16
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
// __WXMSW__
|
||||
#endif // Unix/Windows
|
||||
|
||||
// Get current working directory.
|
||||
// If buf is NULL, allocates space using new, else
|
||||
@@ -1416,6 +1427,11 @@ char *wxGetWorkingDirectory(char *buf, int sz)
|
||||
return buf;
|
||||
}
|
||||
|
||||
wxString wxGetCwd()
|
||||
{
|
||||
return wxString(wxGetWorkingDirectory());
|
||||
}
|
||||
|
||||
bool wxSetWorkingDirectory(const wxString& d)
|
||||
{
|
||||
#if defined( __UNIX__ ) || defined( __WXMAC__ )
|
||||
@@ -1490,11 +1506,14 @@ bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile)
|
||||
|
||||
wxString strFile;
|
||||
char *pc;
|
||||
for ( pc = strtok(szPath, PATH_SEP); pc; pc = strtok((char *) NULL, PATH_SEP) ) {
|
||||
for ( pc = strtok(szPath, wxPATH_SEP);
|
||||
pc != NULL;
|
||||
pc = strtok((char *) NULL, wxPATH_SEP) )
|
||||
{
|
||||
// search for the file in this directory
|
||||
strFile = pc;
|
||||
if ( !wxEndsWithPathSeparator(pc) )
|
||||
strFile += FILE_SEP_PATH;
|
||||
strFile += wxFILE_SEP_PATH;
|
||||
strFile += pszFile;
|
||||
|
||||
if ( FileExists(strFile) ) {
|
||||
@@ -1515,9 +1534,9 @@ void WXDLLEXPORT wxSplitPath(const char *pszFileName,
|
||||
{
|
||||
wxCHECK_RET( pszFileName, "NULL file name in wxSplitPath" );
|
||||
|
||||
const char *pDot = strrchr(pszFileName, FILE_SEP_EXT);
|
||||
const char *pSepUnix = strrchr(pszFileName, FILE_SEP_PATH_UNIX);
|
||||
const char *pSepDos = strrchr(pszFileName, FILE_SEP_PATH_DOS);
|
||||
const char *pDot = strrchr(pszFileName, wxFILE_SEP_EXT);
|
||||
const char *pSepUnix = strrchr(pszFileName, wxFILE_SEP_PATH_UNIX);
|
||||
const char *pSepDos = strrchr(pszFileName, wxFILE_SEP_PATH_DOS);
|
||||
|
||||
// take the last of the two: nPosUnix containts the last slash in the
|
||||
// filename
|
||||
|
@@ -220,10 +220,10 @@ static wxString GetAllMsgCatalogSubdirs(const char *prefix,
|
||||
|
||||
// search first in prefix/fr/LC_MESSAGES, then in prefix/fr and finally in
|
||||
// prefix (assuming the language is 'fr')
|
||||
searchPath << prefix << FILE_SEP_PATH << lang << FILE_SEP_PATH
|
||||
<< "LC_MESSAGES" << PATH_SEP
|
||||
<< prefix << FILE_SEP_PATH << lang << PATH_SEP
|
||||
<< prefix << PATH_SEP;
|
||||
searchPath << prefix << wxFILE_SEP_PATH << lang << wxFILE_SEP_PATH
|
||||
<< "LC_MESSAGES" << wxPATH_SEP
|
||||
<< prefix << wxFILE_SEP_PATH << lang << wxPATH_SEP
|
||||
<< prefix << wxPATH_SEP;
|
||||
|
||||
return searchPath;
|
||||
}
|
||||
@@ -238,17 +238,17 @@ static wxString GetFullSearchPath(const char *lang)
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
searchPath << GetAllMsgCatalogSubdirs(s_searchPrefixes[n], lang)
|
||||
<< PATH_SEP;
|
||||
<< wxPATH_SEP;
|
||||
}
|
||||
|
||||
// then take the current directory
|
||||
// FIXME it should be the directory of the executable
|
||||
searchPath << GetAllMsgCatalogSubdirs(".", lang) << PATH_SEP;
|
||||
searchPath << GetAllMsgCatalogSubdirs(".", lang) << wxPATH_SEP;
|
||||
|
||||
// and finally add some standard ones
|
||||
searchPath
|
||||
<< GetAllMsgCatalogSubdirs("/usr/share/locale", lang) << PATH_SEP
|
||||
<< GetAllMsgCatalogSubdirs("/usr/lib/locale", lang) << PATH_SEP
|
||||
<< GetAllMsgCatalogSubdirs("/usr/share/locale", lang) << wxPATH_SEP
|
||||
<< GetAllMsgCatalogSubdirs("/usr/lib/locale", lang) << wxPATH_SEP
|
||||
<< GetAllMsgCatalogSubdirs("/usr/local/share/locale", lang);
|
||||
|
||||
return searchPath;
|
||||
@@ -273,7 +273,7 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName)
|
||||
// exist
|
||||
searchPath << GetFullSearchPath(wxString(szDirPrefix).
|
||||
Left((size_t)(sublocale - szDirPrefix)))
|
||||
<< PATH_SEP;
|
||||
<< wxPATH_SEP;
|
||||
}
|
||||
|
||||
wxString strFile = szName;
|
||||
|
Reference in New Issue
Block a user