Class Dir
-
Constructor Summary
ConstructorsConstructorDescriptionDir(MemorySegment address) Create a Dir proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the directory immediately and decrements the reference count.static @Nullable TypegetType()Get the GType of the Dir classstatic StringCreates a subdirectory in the preferred directory for temporary files (as returned by g_get_tmp_dir()).static DirOpens a directory for reading.readName()Retrieves the name of another entry in the directory, ornull.ref()Increment the reference count ofdir.voidrewind()Resets the given directory.voidunref()Decrements the reference count ofdir.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Dir
Create a Dir proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
-
Method Details
-
getType
-
open
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.- Parameters:
path- the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8flags- Currently must be set to 0. Reserved for future use.- Returns:
- a newly allocated
GDiron success,nullon failure. If non-null, you must free the result with g_dir_close() when you are finished with it. - Throws:
GErrorException- seeGError
-
makeTmp
Creates a subdirectory in the preferred directory for temporary files (as returned by g_get_tmp_dir()).tmplshould 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 isnull, a default template is used.Note that in contrast to g_mkdtemp() (and mkdtemp())
tmplis not modified, and might thus be a read-only literal string.- Parameters:
tmpl- Template for directory name, as in g_mkdtemp(), basename only, ornullfor a default template- Returns:
- The actual name used. This string
should be freed with g_free() when not needed any longer and is
is in the GLib file name encoding. In case of errors,
nullis returned anderrorwill be set. - Throws:
GErrorException- seeGError- Since:
- 2.30
-
close
public void close()Closes the directory immediately and decrements the reference count.Once the reference count reaches zero, the
GDirstructure itself will be freed. Prior to GLib 2.80,GDirwas not reference counted.It is an error to call any of the
GDirmethods other thanref()andunref()on aGDirafter callingclose()on it. -
readName
Retrieves the name of another entry in the directory, ornull. The order of entries returned from this function is not defined, and may vary by file system or other operating-system dependent factors.nullmay also be returned in case of errors. On Unix, you can checkerrnoto find out ifnullwas 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.
- Returns:
- The entry's name or
nullif there are no more entries. The return value is owned by GLib and must not be modified or freed.
-
ref
-
rewind
public void rewind()Resets the given directory. The next call to g_dir_read_name() will return the first entry again. -
unref
public void unref()Decrements the reference count ofdir.Once the reference count reaches zero, the directory will be closed and all resources associated with it will be freed. If
close()is called when the reference count is greater than zero, the directory is closed but theGDirstructure will not be freed until its reference count reaches zero.It is an error to call any of the
GDirmethods other thanref()andunref()on aGDirafter callingclose()on it.- Since:
- 2.80
-