gi-glib-2.0.30: GLib bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.GLib.Structs.Dir

Description

An opaque structure representing an opened directory.

Synopsis

Exported types

newtype Dir Source #

Memory-managed wrapper type.

Constructors

Dir (ManagedPtr Dir) 

Instances

Instances details
Eq Dir Source # 
Instance details

Defined in GI.GLib.Structs.Dir

Methods

(==) :: Dir -> Dir -> Bool #

(/=) :: Dir -> Dir -> Bool #

GBoxed Dir Source # 
Instance details

Defined in GI.GLib.Structs.Dir

ManagedPtrNewtype Dir Source # 
Instance details

Defined in GI.GLib.Structs.Dir

Methods

toManagedPtr :: Dir -> ManagedPtr Dir

TypedObject Dir Source # 
Instance details

Defined in GI.GLib.Structs.Dir

Methods

glibType :: IO GType

HasParentTypes Dir Source # 
Instance details

Defined in GI.GLib.Structs.Dir

IsGValue (Maybe Dir) Source #

Convert Dir to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.GLib.Structs.Dir

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Dir -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Dir)

type ParentTypes Dir Source # 
Instance details

Defined in GI.GLib.Structs.Dir

type ParentTypes Dir = '[] :: [Type]

Methods

Click to display all available methods, including inherited ones

Expand

Methods

close, readName, ref, rewind, unref.

Getters

None.

Setters

None.

close

dirClose Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Dir

dir: a Dir* created by dirOpen

-> m () 

Closes the directory immediately and decrements the reference count.

Once the reference count reaches zero, the GDir structure itself will be freed. Prior to GLib 2.80, GDir was not reference counted.

It is an error to call any of the GDir methods other than dirRef and dirUnref on a GDir after calling dirClose on it.

makeTmp

dirMakeTmp Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Maybe [Char]

tmpl: Template for directory name, as in g_mkdtemp(), basename only, or Nothing for a default template

-> m [Char]

Returns: The actual name used. This string should be freed with free when not needed any longer and is is in the GLib file name encoding. In case of errors, Nothing is returned and error will be set. (Can throw GError)

Creates a subdirectory in the preferred directory for temporary files (as returned by getTmpDir).

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 Nothing, 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

dirOpen Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

path: the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8

-> Word32

flags: Currently must be set to 0. Reserved for future use.

-> m Dir

Returns: a newly allocated Dir on success, Nothing on failure. If non-Nothing, you must free the result with dirClose when you are finished with it. (Can throw GError)

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

readName

dirReadName Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Dir

dir: a Dir* created by dirOpen

-> m [Char]

Returns: The entry's name or Nothing if there are no more entries. The return value is owned by GLib and must not be modified or freed.

Retrieves the name of another entry in the directory, or Nothing. The order of entries returned from this function is not defined, and may vary by file system or other operating-system dependent factors.

Nothing may also be returned in case of errors. On Unix, you can check errno to find out if Nothing 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.

ref

dirRef Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Dir

dir: a GDir

-> m Dir

Returns: the same pointer as dir

Increment the reference count of dir.

Since: 2.80

rewind

dirRewind Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Dir

dir: a Dir* created by dirOpen

-> m () 

Resets the given directory. The next call to dirReadName will return the first entry again.

unref

dirUnref Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Dir

dir: a GDir

-> m () 

Decrements the reference count of dir.

Once the reference count reaches zero, the directory will be closed and all resources associated with it will be freed. If dirClose is called when the reference count is greater than zero, the directory is closed but the GDir structure will not be freed until its reference count reaches zero.

It is an error to call any of the GDir methods other than dirRef and dirUnref on a GDir after calling dirClose on it.

Since: 2.80