Directory

There is a group of functions which wrap the common POSIX functions dealing with filenames (g_open(), g_rename(), g_mkdir(), g_stat(), g_unlink(), g_remove(), g_fopen(), g_freopen()). The point of these wrappers is to make it possible to handle file names with any Unicode characters in them on Windows without having to use ifdefs and the wide character API in the application code.

The pathname argument should be in the GLib file name encoding. On POSIX this is the actual on-disk encoding which might correspond to the locale settings of the process (or the G_FILENAME_ENCODING environment variable), or not.

On Windows the GLib file name encoding is UTF-8. Note that the Microsoft C library does not use UTF-8, but has separate APIs for current system code page and wide characters (UTF-16). The GLib wrappers call the wide character API if present (on modern Windows systems), otherwise convert to/from the system code page.

Another group of functions allows to open and read directories in the GLib file name encoding. These are g_dir_open(), g_dir_read_name(), g_dir_rewind(), g_dir_close().

Constructors

this
this(GDir* gDir)

Sets our main struct and passes it to the parent class

Members

Functions

close
void close()

Closes the directory and deallocates all related resources.

getDirectoryStruct
GDir* getDirectoryStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

readName
string readName()

Retrieves the name of another entry in the directory, or NULL. The order of entries returned from this function is not defined, and may vary by file system or other operating-system dependent factors. NULL may also be returned in case of errors. On Unix, you can check errno to find out if NULL was returned because of an error. On Unix, the '.' and '..' entries are omitted, and the returned name is in the on-disk encoding. On Windows, as is true of all GLib functions which operate on filenames, the returned name is in UTF-8.

rewind
void rewind()

Resets the given directory. The next call to g_dir_read_name() will return the first entry again.

Static functions

makeTmp
string makeTmp(string tmpl)

Creates a subdirectory in the preferred directory for temporary files (as returned by g_get_tmp_dir()). tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, as the parameter to g_mkstemp(). However, unlike these functions, the template should only be a basename, no directory components are allowed. If template is NULL, a default template is used. Note that in contrast to g_mkdtemp() (and mkdtemp()) tmpl is not modified, and might thus be a read-only literal string. Since 2.30

open
Directory open(string path, uint flags)

Opens a directory for reading. The names of the files in the directory can then be retrieved using g_dir_read_name(). Note that the ordering is not defined.

Variables

gDir
GDir* gDir;

the main Gtk struct

Meta