FileUtils

Members

Static functions

access
int access(string filename, int mode)

A wrapper for the POSIX access() function. This function is used to test a pathname for one or several of read, write or execute permissions, or just existence.

chdir
int chdir(string path)

A wrapper for the POSIX chdir() function. The function changes the current directory of the process to @path.

close
bool close(int fd)

This wraps the close() call; in case of error, %errno will be preserved, but the error will also be stored as a #GError in @error.

fileErrorFromErrno
GFileError fileErrorFromErrno(int errNo)

Gets a #GFileError constant based on the passed-in @err_no. For example, if you pass in EEXIST this function returns #G_FILE_ERROR_EXIST. Unlike errno values, you can portably assume that all #GFileError values will exist.

fileErrorQuark
GQuark fileErrorQuark()
fileGetContents
bool fileGetContents(string filename, string contents)

Reads an entire file into allocated memory, with good error checking.

fileOpenTmp
int fileOpenTmp(string tmpl, string nameUsed)

Opens a file for writing in the preferred directory for temporary files (as returned by g_get_tmp_dir()).

fileReadLink
string fileReadLink(string filename)

Reads the contents of the symbolic link @filename like the POSIX readlink() function. The returned string is in the encoding used for filenames. Use g_filename_to_utf8() to convert it to UTF-8.

fileSetContents
bool fileSetContents(string filename, string contents)

Writes all of @contents to a file named @filename. This is a convenience wrapper around calling g_file_set_contents_full() with flags set to G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING and mode set to 0666.

fileTest
bool fileTest(string filename, GFileTest test)

Returns %TRUE if any of the tests in the bitfield @test are %TRUE. For example, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) will return %TRUE if the file exists; the check whether it's a directory doesn't matter since the existence test is %TRUE. With the current set of available tests, there's no point passing in more than one test at a time.

mkdirWithParents
int mkdirWithParents(string pathname, int mode)

Create a directory if it doesn't already exist. Create intermediate parent directories as needed, too.

mkdtemp
string mkdtemp(string tmpl)

Creates a temporary directory. See the mkdtemp() documentation on most UNIX-like systems.

mkdtempFull
string mkdtempFull(string tmpl, int mode)

Creates a temporary directory. See the mkdtemp() documentation on most UNIX-like systems.

mkstemp
int mkstemp(string tmpl)

Opens a temporary file. See the mkstemp() documentation on most UNIX-like systems.

mkstempFull
int mkstempFull(string tmpl, int flags, int mode)

Opens a temporary file. See the mkstemp() documentation on most UNIX-like systems.

rmdir
int rmdir(string filename)

A wrapper for the POSIX rmdir() function. The rmdir() function deletes a directory from the filesystem.

unlink
int unlink(string filename)

A wrapper for the POSIX unlink() function. The unlink() function deletes a name from the filesystem. If this was the last link to the file and no processes have it opened, the diskspace occupied by the file is freed.

Meta