Contents Up Previous Next

File functions

See also wxPathList.

::wxDirExists
::Dos2UnixFilename
::wxFileExists
::wxFileNameFromPath
::wxFindFirstFile
::wxFindNextFile
::wxIsAbsolutePath
::wxPathOnly
::wxUnix2DosFilename
::wxConcatFiles
::wxCopyFile
::wxGetHostName
::wxGetEmailAddress
::wxGetUserId
::wxGetUserName
::wxGetWorkingDirectory
::wxGetTempFileName
::wxIsWild
::wxMatchWild
::wxMkdir
::wxRemoveFile
::wxRenameFile
::wxRmdir
::wxSetWorkingDirectory


::wxDirExists

Bool wxDirExists(char *dirname)

Returns TRUE if the directory exists.


::Dos2UnixFilename

void Dos2UnixFilename(char *s)

Converts a DOS to a UNIX filename by replacing backslashes with forward slashes.


::wxFileExists

Bool wxFileExists(char *filename)

Returns TRUE if the file exists.


::wxFileNameFromPath

char * wxFileNameFromPath(char *path)

Returns a temporary pointer to the filename for a full path. Copy this pointer for long-term use.


::wxFindFirstFile

char * wxFindFirstFile(const char *spec, int flags = 0)

This function does directory searching; returns the first file that matches the path spec, or NULL. Use wxFindNextFile to get the next matching file.

spec may contain wildcards.

flags is reserved for future use.

The returned filename is a pointer to static memory so should not be freed.

For example:

  char *f = wxFindFirstFile("/home/project/*.*");
  while (f)
  {
    ...
    f = wxFindNextFile();
  }

::wxFindNextFile

char * wxFindFirstFile(void)

Returns the next file that matches the path passed to wxFindFirstFile.


::wxIsAbsolutePath

Bool wxIsAbsolutePath(char *filename)

Returns TRUE if the argument is an absolute filename, i.e. with a slash or drive name at the beginning.


::wxPathOnly

char * wxPathOnly(char *path)

Returns a temporary pointer to the directory part of the filename. Copy this pointer for long-term use.


::wxUnix2DosFilename

void wxUnix2DosFilename(char *s)

Converts a UNIX to a DOS filename by replacing forward slashes with backslashes.


::wxConcatFiles

Bool wxConcatFiles(char *file1, char *file2, char *file3)

Concatenates file1 and file2 to file3, returning TRUE if successful.


::wxCopyFile

Bool wxCopyFile(char *file1, char *file2)

Copies file1 to file2, returning TRUE if successful.


::wxGetHostName

Bool wxGetHostName(char *buf, int sz)

Copies the current host machine's name into the supplied buffer.

Under Windows or NT, this function first looks in the environment variable SYSTEM_NAME; if this is not found, the entry HostName in the wxWindows section of the WIN.INI file is tried.

Returns TRUE if successful, FALSE otherwise.


::wxGetEmailAddress

Bool wxGetEmailAddress(char *buf, int sz)

Copies the user's email address into the supplied buffer, by concatenating the values returned by wxGetHostName and wxGetUserId.

Returns TRUE if successful, FALSE otherwise.


::wxGetUserId

Bool wxGetUserId(char *buf, int sz)

Copies the current user id into the supplied buffer.

Under Windows or NT, this function first looks in the environment variables USER and LOGNAME; if neither of these is found, the entry UserId in the wxWindows section of the WIN.INI file is tried.

Returns TRUE if successful, FALSE otherwise.


::wxGetUserName

Bool wxGetUserName(char *buf, int sz)

Copies the current user name into the supplied buffer.

Under Windows or NT, this function looks for the entry UserName in the wxWindows section of the WIN.INI file. If PenWindows is running, the entry Current in the section User of the PENWIN.INI file is used.

Returns TRUE if successful, FALSE otherwise.


::wxGetWorkingDirectory

char * wxGetWorkingDirectory(char *buf=NULL, int sz=1000)

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.

sz is the size of the buffer if supplied.


::wxGetTempFileName

char * wxGetTempFileName(char *prefix, char *buf=NULL)

Makes a temporary filename based on prefix, opens and closes the file, and places the name in buf. If buf is NULL, new store is allocated for the temporary filename using new.

Under Windows, the filename will include the drive and name of the directory allocated for temporary files (usually the contents of the TEMP variable). Under UNIX, the /tmp directory is used.

It is the application's responsibility to create and delete the file.


::wxIsWild

Bool wxIsWild(char *pattern)

Returns TRUE if the pattern contains wildcards. See wxMatchWild.


::wxMatchWild

Bool wxMatchWild(char *pattern, char *text, Bool dot_special)

Returns TRUE if the pattern matches the text; if dot_special is TRUE, filenames beginning with a dot are not matched with wildcard characters. See wxIsWild.


::wxMkdir

Bool wxMkdir(char *dir)

Makes the directory dir, returning TRUE if successful.


::wxRemoveFile

Bool wxRemoveFile(char *file)

Removes file, returning TRUE if successful.


::wxRenameFile

Bool wxRenameFile(char *file1, char *file2)

Renames file1 to file2, returning TRUE if successful.


::wxRmdir

Bool wxRmdir(char *dir, int flags=0)

Removes the directory dir, returning TRUE if successful. Does not work under VMS.

The flags parameter is reserved for future use.


::wxSetWorkingDirectory

Bool wxSetWorkingDirectory(char *dir)

Sets the current working directory, returning TRUE if the operation succeeded. Under MS Windows, the current drive is also changed if dir contains a drive specification.