{-# LANGUAGE DeriveDataTypeable #-}

{-# LINE 2 "./System/GIO/File/File.chs" #-}
-- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*-
--
-- Author : Peter Gavin, Andy Stewart
-- Created: 13-Oct-2008
--
-- Copyright (c) 2008 Peter Gavin
-- Copyright (c) 2010 Andy Stewart
--
-- This library is free software: you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public License
-- as published by the Free Software Foundation, either version 3 of
-- the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this program. If not, see
-- <http:
--
-- GIO, the C library which this Haskell library depends on, is
-- available under LGPL Version 2. The documentation included with
-- this library is based on the original GIO documentation.
--
-- | Maintainer : gtk2hs-devel@lists.sourceforge.net
-- Stability : alpha
-- Portability : portable (depends on GHC)
module System.GIO.File.File (
-- * Details
--
-- | 'File' is a high level abstraction for manipulating files on a virtual file system. 'File's are
-- lightweight, immutable objects that do no I/O upon creation. It is necessary to understand that
-- 'File' objects do not represent files, merely an identifier for a file. All file content I/O is
-- implemented as streaming operations (see GInputStream and GOutputStream).
--
-- To construct a 'File', you can use: 'fileFromPath' if
-- you have a URI. 'fileNewForCommandlineArg'
-- from a utf8 string gotten from 'fileGetParseName'.
--
-- One way to think of a 'File' is as an abstraction of a pathname. For normal files the system pathname
-- is what is stored internally, but as 'File's are extensible it could also be something else that
-- corresponds to a pathname in a userspace implementation of a filesystem.
--
-- 'File's make up hierarchies of directories and files that correspond to the files on a
-- filesystem. You can move through the file system with 'File' using 'fileGetParent' to get an
-- identifier for the parent directory, 'fileGetChild' to get a child within a directory,
-- 'fileResolveRelativePath' to resolve a relative path between two 'File's. There can be multiple
-- hierarchies, so you may not end up at the same root if you repeatedly call 'fileGetParent' on
-- two different files.
--
-- All 'File's have a basename (get with 'fileGetBasename'. These names are byte strings that are
-- used to identify the file on the filesystem (relative to its parent directory) and there is no
-- guarantees that they have any particular charset encoding or even make any sense at all. If you want
-- to use filenames in a user interface you should use the display name that you can get by requesting
-- the 'FileAttributeStandardDisplayName' attribute with 'fileQueryInfo'. This is guaranteed to
-- be in utf8 and can be used in a user interface. But always store the real basename or the 'File' to
-- use to actually access the file, because there is no way to go from a display name to the actual
-- name.
--
-- Using 'File' as an identifier has the same weaknesses as using a path in that there may be multiple
-- aliases for the same file. For instance, hard or soft links may cause two different 'File's to refer
-- to the same file. Other possible causes for aliases are: case insensitive filesystems, short and
-- long names on Fat/NTFS, or bind mounts in Linux. If you want to check if two 'File's point to the
-- same file you can query for the 'FileAttributeIdFile' attribute. Note that 'File' does some
-- trivial canonicalization of pathnames passed in, so that trivial differences in the path string used
-- at creation (duplicated slashes, slash at end of path, "." or ".." path segments, etc) does not
-- create different 'File's.
--
-- Many 'File' operations have both synchronous and asynchronous versions to suit your
-- application. Asynchronous versions of synchronous functions simply have _async() appended to their
-- function names. The asynchronous I/O functions call a 'AsyncReadyCallback' which is then used to
-- finalize the operation, producing a 'AsyncResult' which is then passed to the function's matching
-- _finish() operation.
--
-- Some 'File' operations do not have synchronous analogs, as they may take a very long time to finish,
-- and blocking may leave an application unusable. Notable cases include: 'fileMountMountable' to
-- mount a mountable file. 'fileUnmountMountableWithOperation' to unmount a mountable
-- file. 'fileEjectMountableWithOperation' to eject a mountable file.
--
-- One notable feature of 'File's are entity tags, or "etags" for short. Entity tags are somewhat like a
-- more abstract version of the traditional mtime, and can be used to quickly determine if the file has
-- been modified from the version on the file system. See the HTTP 1.1 specification for HTTP Etag
-- headers, which are a very similar concept.

-- * Types.
    File(..),
    FileClass,
    FileProgressCallback,
    FileReadMoreCallback,
    Offset,
    FileInputStream,
    FileInputStreamClass,
    FileOutputStream,
    FileOutputStreamClass,
    InputStream,
    InputStreamClass,
    OutputStream,
    OutputStreamClass,
    BufferedInputStream,
    BufferedInputStreamClass,
    BufferedOutputStream,
    BufferedOutputStreamClass,
    MemoryInputStream,
    MemoryInputStreamClass,
    MemoryOutputStream,
    MemoryOutputStreamClass,
    FilterInputStream,
    FilterInputStreamClass,
    FilterOutputStream,
    FilterOutputStreamClass,
    DataInputStream,
    DataInputStreamClass,
    DataOutputStream,
    DataOutputStreamClass,

-- * Enums
    FileType (..),
    FileCopyFlags (..),
    FileQueryInfoFlags (..),
    FileCreateFlags (..),
    FileMonitorFlags (..),
    MountMountFlags (..),
    MountUnmountFlags (..),

-- * Methods
    fileFromPath,
    fileFromURI,
    fileFromCommandlineArg,
    fileFromParseName,
    fileEqual,
    fileBasename,
    filePath,

    fileHasParent,

    fileURI,
    fileParseName,
    fileGetChild,
    fileGetChildForDisplayName,
    fileHasPrefix,
    fileGetRelativePath,
    fileResolveRelativePath,
    fileIsNative,
    fileHasURIScheme,
    fileURIScheme,
    fileRead,
    fileReadAsync,
    fileReadFinish,
    fileAppendTo,
    fileCreate,
    fileReplace,
    fileAppendToAsync,
    fileAppendToFinish,
    fileCreateAsync,
    fileCreateFinish,
    fileReplaceAsync,
    fileReplaceFinish,
    fileQueryInfo,
    fileQueryInfoAsync,
    fileQueryInfoFinish,
    fileQueryExists,

    fileQueryFileType,

    fileQueryFilesystemInfo,
    fileQueryFilesystemInfoAsync,
    fileQueryFilesystemInfoFinish,
    fileQueryDefaultHandler,
    fileFindEnclosingMount,
    fileFindEnclosingMountAsync,
    fileFindEnclosingMountFinish,
    fileEnumerateChildren,
    fileEnumerateChildrenAsync,
    fileEnumerateChildrenFinish,
    fileSetDisplayName,
    fileSetDisplayNameAsync,
    fileSetDisplayNameFinish,
    fileDelete,
    fileTrash,
    fileCopy,
    fileCopyAsync,
    fileCopyFinish,
    fileMove,
    fileMakeDirectory,

    fileMakeDirectoryWithParents,

    fileMakeSymbolicLink,
    fileQuerySettableAttributes,
    fileQueryWritableNamespaces,

    fileSetAttributesFromInfo,
    fileSetAttributesFromInfoAsync,
    fileSetAttributesFinish,
    fileSetAttributeString,
    fileSetAttributeByteString,
    fileSetAttributeWord32,
    fileSetAttributeInt32,
    fileSetAttributeWord64,
    fileSetAttributeInt64,
    fileCopyAttributes,

    fileMonitorDirectory,
    fileMonitorFile,

    fileMonitor,


    fileMountMountable,
    fileMountMountableFinish,

    fileUnmountMountableWithOperation,
    fileUnmountMountableWithOperationFinish,
    fileEjectMountableWithOperation,
    fileEjectMountableWithOperationFinish,
    fileStartMountable,
    fileStartMountableFinish,
    fileStopMountable,
    fileStopMountableFinish,
    filePollMountable,
    filePollMountableFinish,
    fileMountEnclosingVolume,
    fileMountEnclosingVolumeFinish,
    fileSupportsThreadContexts,

) where

import Control.Monad
import Data.Typeable
import Data.Maybe (fromMaybe)
import Data.ByteString (ByteString)
import Data.ByteString (useAsCString)
import Data.ByteString.Unsafe (unsafePackCStringFinalizer)
import System.GIO.Enums
import System.GIO.File.FileAttribute
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.GObject
import System.Glib.UTFString
import System.GIO.Async.AsyncResult
{-# LINE 245 "./System/GIO/File/File.chs" #-}
import System.GIO.Types
{-# LINE 246 "./System/GIO/File/File.chs" #-}

import qualified Data.ByteString as BS


{-# LINE 250 "./System/GIO/File/File.chs" #-}

type Offset = (CLong)
{-# LINE 252 "./System/GIO/File/File.chs" #-}

type GFileProgressCallback = FunPtr ((CLong -> (CLong -> ((Ptr ()) -> (IO ())))))
{-# LINE 254 "./System/GIO/File/File.chs" #-}

type FileProgressCallback = Offset -> Offset -> IO ()

foreign import ccall "wrapper" mkFileProgressCallback ::
     ((CLong) -> (CLong) -> Ptr () -> IO ()) -> IO GFileProgressCallback

marshalFileProgressCallback :: FileProgressCallback -> IO GFileProgressCallback
marshalFileProgressCallback :: FileProgressCallback -> IO GFileProgressCallback
marshalFileProgressCallback FileProgressCallback
fileProgressCallback =
    (CLong -> CLong -> Ptr () -> IO ()) -> IO GFileProgressCallback
mkFileProgressCallback ((CLong -> CLong -> Ptr () -> IO ()) -> IO GFileProgressCallback)
-> (CLong -> CLong -> Ptr () -> IO ()) -> IO GFileProgressCallback
forall a b. (a -> b) -> a -> b
$ \ CLong
cCurrentNumBytes CLong
cTotalNumBytes Ptr ()
_ -> do
      FileProgressCallback
fileProgressCallback
        (CLong -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral CLong
cCurrentNumBytes)
        (CLong -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral CLong
cTotalNumBytes)

type FileReadMoreCallback = BS.ByteString -> IO Bool

-- | Constructs a 'File' for a given path. This operation never fails, but the returned object might not
-- support any I/O operation if path is malformed.
fileFromPath :: ByteString -> File
fileFromPath :: ByteString -> File
fileFromPath ByteString
path =
    IO File -> File
forall a. IO a -> a
unsafePerformIO (IO File -> File) -> IO File -> File
forall a b. (a -> b) -> a -> b
$ (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
    ByteString -> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a. ByteString -> (CString -> IO a) -> IO a
useAsCString ByteString
path ((CString -> IO (Ptr File)) -> IO (Ptr File))
-> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \CString
cPath -> CString -> IO (Ptr File)
g_file_new_for_path CString
cPath

-- | Constructs a 'File' for a given URI. This operation never fails, but the returned object might not
-- support any I/O operation if uri is malformed or if the uri type is not supported.
fileFromURI :: GlibString string => string -> File
fileFromURI :: forall string. GlibString string => string -> File
fileFromURI string
uri =
    IO File -> File
forall a. IO a -> a
unsafePerformIO (IO File -> File) -> IO File -> File
forall a b. (a -> b) -> a -> b
$ (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
    string -> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
uri ((CString -> IO (Ptr File)) -> IO (Ptr File))
-> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \CString
cURI -> CString -> IO (Ptr File)
g_file_new_for_uri CString
cURI

-- | Creates a 'File' with the given argument from the command line. The value of arg can be either a URI,
-- an absolute path or a relative path resolved relative to the current working directory. This
-- operation never fails, but the returned object might not support any I/O operation if arg points to
-- a malformed path.
fileFromCommandlineArg :: ByteString -> File
fileFromCommandlineArg :: ByteString -> File
fileFromCommandlineArg ByteString
arg =
    IO File -> File
forall a. IO a -> a
unsafePerformIO (IO File -> File) -> IO File -> File
forall a b. (a -> b) -> a -> b
$ (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
    ByteString -> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a. ByteString -> (CString -> IO a) -> IO a
useAsCString ByteString
arg ((CString -> IO (Ptr File)) -> IO (Ptr File))
-> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \CString
cArg -> CString -> IO (Ptr File)
g_file_new_for_commandline_arg CString
cArg

-- | Constructs a 'File' with the given name (i.e. something given by 'fileParseName'. This
-- operation never fails, but the returned object might not support any I/O operation if the @parseName@
-- cannot be parsed.
fileFromParseName :: GlibString string => string -> File
fileFromParseName :: forall string. GlibString string => string -> File
fileFromParseName string
parseName =
    IO File -> File
forall a. IO a -> a
unsafePerformIO (IO File -> File) -> IO File -> File
forall a b. (a -> b) -> a -> b
$ (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
    string -> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
parseName ((CString -> IO (Ptr File)) -> IO (Ptr File))
-> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \CString
cParseName -> CString -> IO (Ptr File)
g_file_parse_name CString
cParseName

-- | Compare two file descriptors for equality. This test is also used to
-- implement the '(==)' function, that is, comparing two descriptions
-- will compare their content, not the pointers to the two structures.
--
fileEqual :: (FileClass file1, FileClass file2)
          => file1 -> file2 -> Bool
fileEqual :: forall file1 file2.
(FileClass file1, FileClass file2) =>
file1 -> file2 -> Bool
fileEqual file1
file1 file2
file2 =
    IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> IO Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) (File ForeignPtr File
arg2) -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg2 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr2 ->Ptr File -> Ptr File -> IO CInt
g_file_equal Ptr File
argPtr1 Ptr File
argPtr2) (file1 -> File
forall o. FileClass o => o -> File
toFile file1
file1) (file2 -> File
forall o. FileClass o => o -> File
toFile file2
file2)

instance Eq File where
    == :: File -> File -> Bool
(==) = File -> File -> Bool
forall file1 file2.
(FileClass file1, FileClass file2) =>
file1 -> file2 -> Bool
fileEqual

-- | Gets the base name (the last component of the path) for a given 'File'.
--
-- If called for the top level of a system (such as the filesystem root or a uri like sftp:
-- will return a single directory separator (and on Windows, possibly a drive letter).
--
-- The base name is a byte string (*not* UTF-8). It has no defined encoding or rules other than it may
-- not contain zero bytes. If you want to use filenames in a user interface you should use the display
-- name that you can get by requesting the 'FileAttributeStandardDisplayName' attribute with
-- 'fileQueryInfo'.
--
-- This call does no blocking i/o.
fileBasename :: FileClass file => file -> ByteString
fileBasename :: forall file. FileClass file => file -> ByteString
fileBasename file
file =
    IO ByteString -> ByteString
forall a. IO a -> a
unsafePerformIO (IO ByteString -> ByteString) -> IO ByteString -> ByteString
forall a b. (a -> b) -> a -> b
$ do
    CString
sPtr <- (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CString) -> IO CString)
-> (Ptr File -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO CString
g_file_get_basename Ptr File
argPtr1)
{-# LINE 327 "./System/GIO/File/File.chs" #-}
               (file -> File
forall o. FileClass o => o -> File
toFile file
file)
    Int
sLen <- CChar -> CString -> IO Int
forall a. (Storable a, Eq a) => a -> Ptr a -> IO Int
lengthArray0 CChar
0 CString
sPtr
    Ptr Word8 -> Int -> IO () -> IO ByteString
unsafePackCStringFinalizer (CString -> Ptr Word8
forall a b. Ptr a -> Ptr b
castPtr CString
sPtr) (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
sLen)
        (Ptr () -> IO ()
g_free (CString -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr CString
sPtr))

-- | Gets the local pathname for 'File', if one exists.
--
-- This call does no blocking i/o.
filePath :: FileClass file => file -> ByteString
filePath :: forall file. FileClass file => file -> ByteString
filePath file
file =
    IO ByteString -> ByteString
forall a. IO a -> a
unsafePerformIO (IO ByteString -> ByteString) -> IO ByteString -> ByteString
forall a b. (a -> b) -> a -> b
$ do
    CString
sPtr <- (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CString) -> IO CString)
-> (Ptr File -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO CString
g_file_get_path Ptr File
argPtr1)
{-# LINE 339 "./System/GIO/File/File.chs" #-}
                (file -> File
forall o. FileClass o => o -> File
toFile file
file)
    Int
sLen <- CChar -> CString -> IO Int
forall a. (Storable a, Eq a) => a -> Ptr a -> IO Int
lengthArray0 CChar
0 CString
sPtr
    Ptr Word8 -> Int -> IO () -> IO ByteString
unsafePackCStringFinalizer (CString -> Ptr Word8
forall a b. Ptr a -> Ptr b
castPtr CString
sPtr) (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
sLen)
        (Ptr () -> IO ()
g_free (CString -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr CString
sPtr))

-- | Gets the URI for the file.
--
-- This call does no blocking i/o.
fileURI :: (FileClass file, GlibString string) => file -> string
fileURI :: forall file string.
(FileClass file, GlibString string) =>
file -> string
fileURI file
file =
    IO string -> string
forall a. IO a -> a
unsafePerformIO (IO string -> string) -> IO string -> string
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CString) -> IO CString)
-> (Ptr File -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO CString
g_file_get_uri Ptr File
argPtr1) (file -> File
forall o. FileClass o => o -> File
toFile file
file) IO CString -> (CString -> IO string) -> IO string
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CString -> IO string
forall s. GlibString s => CString -> IO s
readUTFString

-- | Gets the parse name of the file. A parse name is a UTF-8 string that describes the file such that
-- one can get the 'File' back using 'fileParseName'.
--
-- This is generally used to show the 'File' as a nice full-pathname kind of string in a user interface,
-- like in a location entry.
--
-- For local files with names that can safely be converted to UTF8 the pathname is used, otherwise the
-- IRI is used (a form of URI that allows UTF8 characters unescaped).
--
-- This call does no blocking i/o.
fileParseName :: (FileClass file, GlibString string) => file -> string
fileParseName :: forall file string.
(FileClass file, GlibString string) =>
file -> string
fileParseName file
file =
    IO string -> string
forall a. IO a -> a
unsafePerformIO (IO string -> string) -> IO string -> string
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CString) -> IO CString)
-> (Ptr File -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO CString
g_file_get_parse_name Ptr File
argPtr1) (file -> File
forall o. FileClass o => o -> File
toFile file
file) IO CString -> (CString -> IO string) -> IO string
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CString -> IO string
forall s. GlibString s => CString -> IO s
readUTFString

-- | Gets the parent directory for the file. If the file represents the root directory of the file
-- system, then 'Nothing' will be returned.
--
-- This call does no blocking i/o.
fileParent :: FileClass file => file -> Maybe File
fileParent :: forall file. FileClass file => file -> Maybe File
fileParent file
file =
    IO (Maybe File) -> Maybe File
forall a. IO a -> a
unsafePerformIO (IO (Maybe File) -> Maybe File) -> IO (Maybe File) -> Maybe File
forall a b. (a -> b) -> a -> b
$ (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO (Maybe File)
forall a. (IO (Ptr a) -> IO a) -> IO (Ptr a) -> IO (Maybe a)
maybeNull ((ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile) (IO (Ptr File) -> IO (Maybe File))
-> IO (Ptr File) -> IO (Maybe File)
forall a b. (a -> b) -> a -> b
$
    (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO (Ptr File)
g_file_get_parent Ptr File
argPtr1) (file -> File
forall o. FileClass o => o -> File
toFile file
file)


-- | Checks if file has a parent, and optionally, if it is parent.
--
-- If parent is 'Nothing' then this function returns 'True' if file has any parent at all. If parent is
-- non-'Nothing' then 'True' is only returned if file is a child of parent.
fileHasParent :: FileClass file => file -> Maybe File -> Bool
fileHasParent :: forall file. FileClass file => file -> Maybe File -> Bool
fileHasParent file
file Maybe File
parent =
    IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> IO Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
    (\(File ForeignPtr File
arg1) (File ForeignPtr File
arg2) -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg2 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr2 ->Ptr File -> Ptr File -> IO CInt
g_file_has_parent Ptr File
argPtr1 Ptr File
argPtr2)
{-# LINE 383 "./System/GIO/File/File.chs" #-}
    (toFile file)
    (File -> Maybe File -> File
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr File -> File
File ForeignPtr File
forall a. ForeignPtr a
nullForeignPtr) Maybe File
parent)


-- | Gets a child of file with basename equal to name.
--
-- Note that the file with that specific name might not exist, but you can still have a 'File' that
-- points to it. You can use this for instance to create that file.
--
-- This call does no blocking i/o.
fileGetChild :: FileClass file => file -> ByteString -> File
fileGetChild :: forall file. FileClass file => file -> ByteString -> File
fileGetChild file
file ByteString
name =
    IO File -> File
forall a. IO a -> a
unsafePerformIO (IO File -> File) -> IO File -> File
forall a b. (a -> b) -> a -> b
$ (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
        ByteString -> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a. ByteString -> (CString -> IO a) -> IO a
useAsCString ByteString
name ((CString -> IO (Ptr File)) -> IO (Ptr File))
-> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \CString
cName ->
        (\(File ForeignPtr File
arg1) CString
arg2 -> ForeignPtr File -> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> CString -> IO (Ptr File)
g_file_get_child Ptr File
argPtr1 CString
arg2) (file -> File
forall o. FileClass o => o -> File
toFile file
file) CString
cName

-- | Gets the child of file for a given 'name (i.e. a UTF8 version of the name)'. If this function
-- fails, it throws a GError. This is very useful when constructing a 'File' for a
-- new file and the user entered the filename in the user interface, for instance when you select a
-- directory and type a filename in the file selector.
--
-- This call does no blocking i/o.
fileGetChildForDisplayName :: (FileClass file, GlibString string) => file -> string -> File
fileGetChildForDisplayName :: forall file string.
(FileClass file, GlibString string) =>
file -> string -> File
fileGetChildForDisplayName file
file string
displayName =
    IO File -> File
forall a. IO a -> a
unsafePerformIO (IO File -> File) -> IO File -> File
forall a b. (a -> b) -> a -> b
$ ((ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile) (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
        string -> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
displayName ((CString -> IO (Ptr File)) -> IO (Ptr File))
-> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \CString
cDisplayName ->
        (Ptr (Ptr ()) -> IO (Ptr File)) -> IO (Ptr File)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CString
arg2 Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> CString -> Ptr (Ptr ()) -> IO (Ptr File)
g_file_get_child_for_display_name Ptr File
argPtr1 CString
arg2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) CString
cDisplayName)

-- | Checks whether file has the prefix specified by prefix. In other word, if the names of initial
-- elements of files pathname match prefix. Only full pathname elements are matched, so a path like
-- /foo is not considered a prefix of /foobar, only of / foo/bar.
--
-- This call does no i/o, as it works purely on names. As such it can sometimes return 'False' even if
-- file is inside a prefix (from a filesystem point of view), because the prefix of file is an alias of
-- prefix.
fileHasPrefix :: (FileClass file1, FileClass file2) => file1 -> file2 -> Bool
fileHasPrefix :: forall file1 file2.
(FileClass file1, FileClass file2) =>
file1 -> file2 -> Bool
fileHasPrefix file1
file1 file2
file2 =
    IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> IO Bool -> Bool
forall a b. (a -> b) -> a -> b
$
        (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) (File ForeignPtr File
arg2) -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg2 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr2 ->Ptr File -> Ptr File -> IO CInt
g_file_has_prefix Ptr File
argPtr1 Ptr File
argPtr2) (file1 -> File
forall o. FileClass o => o -> File
toFile file1
file1) (file2 -> File
forall o. FileClass o => o -> File
toFile file2
file2)

-- | Gets the path for descendant relative to parent.
--
-- This call does no blocking i/o.
fileGetRelativePath :: (FileClass file1, FileClass file2) => file1 -> file2 -> Maybe ByteString
fileGetRelativePath :: forall file1 file2.
(FileClass file1, FileClass file2) =>
file1 -> file2 -> Maybe ByteString
fileGetRelativePath file1
file1 file2
file2 =
    IO (Maybe ByteString) -> Maybe ByteString
forall a. IO a -> a
unsafePerformIO (IO (Maybe ByteString) -> Maybe ByteString)
-> IO (Maybe ByteString) -> Maybe ByteString
forall a b. (a -> b) -> a -> b
$ do
    CString
sPtr <- (\(File ForeignPtr File
arg1) (File ForeignPtr File
arg2) -> ForeignPtr File -> (Ptr File -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CString) -> IO CString)
-> (Ptr File -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr File -> (Ptr File -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg2 ((Ptr File -> IO CString) -> IO CString)
-> (Ptr File -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr2 ->Ptr File -> Ptr File -> IO CString
g_file_get_relative_path Ptr File
argPtr1 Ptr File
argPtr2) (file1 -> File
forall o. FileClass o => o -> File
toFile file1
file1) (file2 -> File
forall o. FileClass o => o -> File
toFile file2
file2)
    if CString
sPtr CString -> CString -> Bool
forall a. Eq a => a -> a -> Bool
== CString
forall a. Ptr a
nullPtr
       then Maybe ByteString -> IO (Maybe ByteString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ByteString
forall a. Maybe a
Nothing
       else do
         Int
sLen <- CChar -> CString -> IO Int
forall a. (Storable a, Eq a) => a -> Ptr a -> IO Int
lengthArray0 CChar
0 CString
sPtr
         (ByteString -> Maybe ByteString)
-> IO ByteString -> IO (Maybe ByteString)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (IO ByteString -> IO (Maybe ByteString))
-> IO ByteString -> IO (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ Ptr Word8 -> Int -> IO () -> IO ByteString
unsafePackCStringFinalizer (CString -> Ptr Word8
forall a b. Ptr a -> Ptr b
castPtr CString
sPtr) (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
sLen)
                          (Ptr () -> IO ()
g_free (CString -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr CString
sPtr))

-- | Resolves a relative path for file to an absolute path.
--
-- This call does no blocking i/o.
fileResolveRelativePath :: FileClass file => file -> ByteString -> Maybe File
fileResolveRelativePath :: forall file. FileClass file => file -> ByteString -> Maybe File
fileResolveRelativePath file
file ByteString
relativePath =
    IO (Maybe File) -> Maybe File
forall a. IO a -> a
unsafePerformIO (IO (Maybe File) -> Maybe File) -> IO (Maybe File) -> Maybe File
forall a b. (a -> b) -> a -> b
$ (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO (Maybe File)
forall a. (IO (Ptr a) -> IO a) -> IO (Ptr a) -> IO (Maybe a)
maybeNull ((ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile) (IO (Ptr File) -> IO (Maybe File))
-> IO (Ptr File) -> IO (Maybe File)
forall a b. (a -> b) -> a -> b
$
        ByteString -> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a. ByteString -> (CString -> IO a) -> IO a
useAsCString ByteString
relativePath ((CString -> IO (Ptr File)) -> IO (Ptr File))
-> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \CString
cRelativePath ->
        (\(File ForeignPtr File
arg1) CString
arg2 -> ForeignPtr File -> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> CString -> IO (Ptr File)
g_file_resolve_relative_path Ptr File
argPtr1 CString
arg2) (file -> File
forall o. FileClass o => o -> File
toFile file
file) CString
cRelativePath

-- | Checks to see if a file is native to the platform.
--
-- A native file s one expressed in the platform-native filename format, e.g. \"C:\Windows\" or
-- \"/usr/bin/\". This does not mean the file is local, as it might be on a locally mounted remote
-- filesystem.
--
-- On some systems non-native files may be available using the native filesystem via a userspace
-- filesystem (FUSE), in these cases this call will return 'False', but 'fileGetPath' will still
-- return a native path.
--
-- This call does no blocking i/o.
fileIsNative :: FileClass file => file -> Bool
fileIsNative :: forall file. FileClass file => file -> Bool
fileIsNative =
    IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> (file -> IO Bool) -> file -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
        (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> (file -> IO CInt) -> file -> IO Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO CInt
g_file_is_native Ptr File
argPtr1) (File -> IO CInt) -> (file -> File) -> file -> IO CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. file -> File
forall o. FileClass o => o -> File
toFile

-- | Checks to see if a 'File' has a given URI scheme.
--
-- This call does no blocking i/o.
fileHasURIScheme :: (FileClass file, GlibString string) => file -> string -> Bool
fileHasURIScheme :: forall file string.
(FileClass file, GlibString string) =>
file -> string -> Bool
fileHasURIScheme file
file string
uriScheme =
    IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> IO Bool -> Bool
forall a b. (a -> b) -> a -> b
$
        string -> (CString -> IO Bool) -> IO Bool
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
uriScheme ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \CString
cURIScheme ->
        (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) CString
arg2 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> CString -> IO CInt
g_file_has_uri_scheme Ptr File
argPtr1 CString
arg2) (file -> File
forall o. FileClass o => o -> File
toFile file
file) CString
cURIScheme

-- | Gets the URI scheme for a 'File'. RFC 3986 decodes the scheme as:
--
-- URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
--
-- Common schemes include "file", "http", "ftp", etc.
--
-- This call does no blocking i/o.
fileURIScheme :: (FileClass file, GlibString string) => file -> string
fileURIScheme :: forall file string.
(FileClass file, GlibString string) =>
file -> string
fileURIScheme file
file =
    IO string -> string
forall a. IO a -> a
unsafePerformIO (IO string -> string) -> IO string -> string
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO CString) -> IO CString
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CString) -> IO CString)
-> (Ptr File -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO CString
g_file_get_uri_scheme Ptr File
argPtr1) (file -> File
forall o. FileClass o => o -> File
toFile file
file) IO CString -> (CString -> IO string) -> IO string
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CString -> IO string
forall s. GlibString s => CString -> IO s
readUTFString

-- | Opens a file for reading. The result is a 'FileInputStream' that can be used to read the contents of
-- the file.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- If the file does not exist, the 'IoErrorNotFound' error will be returned. If the file is a
-- directory, the 'IoErrorIsDirectory' error will be returned. Other errors are possible too, and
-- depend on what kind of filesystem the file is on.
fileRead :: FileClass file => file -> Maybe Cancellable -> IO FileInputStream
fileRead :: forall file.
FileClass file =>
file -> Maybe Cancellable -> IO FileInputStream
fileRead file
file Maybe Cancellable
cancellable =
    (ForeignPtr FileInputStream -> FileInputStream,
 FinalizerPtr FileInputStream)
-> IO (Ptr FileInputStream) -> IO FileInputStream
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileInputStream -> FileInputStream,
 FinalizerPtr FileInputStream)
forall {a}.
(ForeignPtr FileInputStream -> FileInputStream, FinalizerPtr a)
mkFileInputStream (IO (Ptr FileInputStream) -> IO FileInputStream)
-> IO (Ptr FileInputStream) -> IO FileInputStream
forall a b. (a -> b) -> a -> b
$
            (Ptr (Ptr ()) -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileInputStream))
 -> IO (Ptr FileInputStream))
-> (Ptr File -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO (Ptr FileInputStream))
 -> IO (Ptr FileInputStream))
-> (Ptr Cancellable -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File
-> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr FileInputStream)
g_file_read Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 496 "./System/GIO/File/File.chs" #-}
                              (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                              (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable))

-- | Asynchronously opens file for reading.
--
-- For more details, see 'fileRead' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call 'fileReadFinish' to
-- get the result of the operation.
fileReadAsync :: FileClass file
              => file
              -> Int
              -> Maybe Cancellable
              -> AsyncReadyCallback
              -> IO ()
fileReadAsync :: forall file.
FileClass file =>
file -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO ()
fileReadAsync file
file Int
ioPriority Maybe Cancellable
mbCancellable AsyncReadyCallback
callback = do
  GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
  (\(File ForeignPtr File
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) GAsyncReadyCallback
arg4 Ptr ()
arg5 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_read_async Ptr File
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3 GAsyncReadyCallback
arg4 Ptr ()
arg5)
{-# LINE 514 "./System/GIO/File/File.chs" #-}
     (toFile file)
     (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
     (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
mbCancellable)
     GAsyncReadyCallback
cCallback
     (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an asynchronous file read operation started with 'fileReadAsync'.
fileReadFinish :: FileClass file
               => file
               -> AsyncResult
               -> IO FileInputStream
fileReadFinish :: forall file.
FileClass file =>
file -> AsyncResult -> IO FileInputStream
fileReadFinish file
file AsyncResult
asyncResult =
    (ForeignPtr FileInputStream -> FileInputStream,
 FinalizerPtr FileInputStream)
-> IO (Ptr FileInputStream) -> IO FileInputStream
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileInputStream -> FileInputStream,
 FinalizerPtr FileInputStream)
forall {a}.
(ForeignPtr FileInputStream -> FileInputStream, FinalizerPtr a)
mkFileInputStream (IO (Ptr FileInputStream) -> IO FileInputStream)
-> IO (Ptr FileInputStream) -> IO FileInputStream
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileInputStream))
 -> IO (Ptr FileInputStream))
-> (Ptr File -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr FileInputStream))
 -> IO (Ptr FileInputStream))
-> (Ptr AsyncResult -> IO (Ptr FileInputStream))
-> IO (Ptr FileInputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File
-> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr FileInputStream)
g_file_read_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Gets an output stream for appending data to the file. If the file doesn't already exist it is
-- created.
--
-- By default files created are generally readable by everyone, but if you pass 'FileCreatePrivate'
-- in flags the file will be made readable only to the current user, to the level that is supported on
-- the target filesystem.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- Some file systems don't allow all file names, and may return an 'IoErrorInvalidFilename'
-- error. If the file is a directory the 'IoErrorIsDirectory' error will be returned. Other errors
-- are possible too, and depend on what kind of filesystem the file is on.
fileAppendTo :: FileClass file
             => file
             -> [FileCreateFlags]
             -> Maybe Cancellable
             -> IO FileOutputStream
fileAppendTo :: forall file.
FileClass file =>
file
-> [FileCreateFlags] -> Maybe Cancellable -> IO FileOutputStream
fileAppendTo file
file [FileCreateFlags]
flags Maybe Cancellable
cancellable =
    (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
forall {a}.
(ForeignPtr FileOutputStream -> FileOutputStream, FinalizerPtr a)
mkFileOutputStream (IO (Ptr FileOutputStream) -> IO FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall a b. (a -> b) -> a -> b
$
        (Ptr (Ptr ()) -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) Ptr (Ptr ())
arg4 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr Cancellable -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO (Ptr FileOutputStream)
g_file_append_to Ptr File
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3 Ptr (Ptr ())
arg4)
{-# LINE 551 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCreateFlags] -> Int) -> [FileCreateFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCreateFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCreateFlags]
flags)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        )

-- | Creates a new file and returns an output stream for writing to it. The file must not already exist.
--
-- By default files created are generally readable by everyone, but if you pass 'FileCreatePrivate'
-- in flags the file will be made readable only to the current user, to the level that is supported on
-- the target filesystem.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- If a file or directory with this name already exists the 'IoErrorExists' error will be
-- returned. Some file systems don't allow all file names, and may return an
-- 'IoErrorInvalidFilename' error, and if the name is to long 'IoErrorFilenameTooLong' will be
-- returned. Other errors are possible too, and depend on what kind of filesystem the file is on.
fileCreate :: FileClass file
           => file
           -> [FileCreateFlags]
           -> Maybe Cancellable
           -> IO FileOutputStream
fileCreate :: forall file.
FileClass file =>
file
-> [FileCreateFlags] -> Maybe Cancellable -> IO FileOutputStream
fileCreate file
file [FileCreateFlags]
flags Maybe Cancellable
cancellable =
    (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
forall {a}.
(ForeignPtr FileOutputStream -> FileOutputStream, FinalizerPtr a)
mkFileOutputStream (IO (Ptr FileOutputStream) -> IO FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall a b. (a -> b) -> a -> b
$
        (Ptr (Ptr ()) -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) Ptr (Ptr ())
arg4 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr Cancellable -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO (Ptr FileOutputStream)
g_file_create Ptr File
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3 Ptr (Ptr ())
arg4)
{-# LINE 578 "./System/GIO/File/File.chs" #-}
                          (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                         ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCreateFlags] -> Int) -> [FileCreateFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCreateFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCreateFlags]
flags)
                         (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        )

-- | Returns an output stream for overwriting the file, possibly creating a backup copy of the file
-- first. If the file doesn't exist, it will be created.
--
-- This will try to replace the file in the safest way possible so that any errors during the writing
-- will not affect an already existing copy of the file. For instance, for local files it may write to
-- a temporary file and then atomically rename over the destination when the stream is closed.
--
-- By default files created are generally readable by everyone, but if you pass 'FileCreatePrivate'
-- in flags the file will be made readable only to the current user, to the level that is supported on
-- the target filesystem.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- If you pass in a non-'Nothing' etag value, then this value is compared to the current entity tag of the
-- file, and if they differ an 'IoErrorWrongEtag' error is returned. This generally means that the
-- file has been changed since you last read it. You can get the new etag from
-- 'fileOutputStreamGetEtag' after you've finished writing and closed the 'FileOutputStream'.
-- When you load a new file you can use 'fileInputStreamQueryInfo' to get the etag of the file.
--
-- If @makeBackup@ is 'True', this function will attempt to make a backup of the current file before
-- overwriting it. If this fails a 'IoErrorCantCreateBackup' error will be returned. If you want to
-- replace anyway, try again with @makeBackup@ set to 'False'.
--
-- If the file is a directory the 'IoErrorIsDirectory' error will be returned, and if the file is
-- some other form of non-regular file then a 'IoErrorNotRegularFile' error will be returned. Some
-- file systems don't allow all file names, and may return an 'IoErrorInvalidFilename' error, and if
-- the name is to long 'IoErrorFilenameTooLong' will be returned. Other errors are possible too,
-- and depend on what kind of filesystem the file is on.
fileReplace :: (FileClass file, GlibString string)
            => file
            -> Maybe string
            -> Bool
            -> [FileCreateFlags]
            -> Maybe Cancellable
            -> IO FileOutputStream
fileReplace :: forall file string.
(FileClass file, GlibString string) =>
file
-> Maybe string
-> Bool
-> [FileCreateFlags]
-> Maybe Cancellable
-> IO FileOutputStream
fileReplace file
file Maybe string
etag Bool
makeBackup [FileCreateFlags]
flags Maybe Cancellable
cancellable =
    (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
forall {a}.
(ForeignPtr FileOutputStream -> FileOutputStream, FinalizerPtr a)
mkFileOutputStream (IO (Ptr FileOutputStream) -> IO FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall a b. (a -> b) -> a -> b
$
        (string
 -> (CString -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> Maybe string
-> (CString -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith string
-> (CString -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString Maybe string
etag ((CString -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (CString -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \CString
cEtag ->
        (Ptr (Ptr ()) -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) Ptr (Ptr ())
arg6 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr Cancellable -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CInt
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO (Ptr FileOutputStream)
g_file_replace Ptr File
argPtr1 CString
arg2 CInt
arg3 CInt
arg4 Ptr Cancellable
argPtr5 Ptr (Ptr ())
arg6)
{-# LINE 624 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           CString
cEtag
                           (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
makeBackup)
                           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCreateFlags] -> Int) -> [FileCreateFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCreateFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCreateFlags]
flags)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable))

-- | Asynchronously opens file for appending.
--
-- For more details, see 'fileAppendTo' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call 'fileAppendToFinish'
-- to get the result of the operation.
fileAppendToAsync :: FileClass file
                  => file
                  -> [FileCreateFlags]
                  -> Int
                  -> Maybe Cancellable
                  -> AsyncReadyCallback
                  -> IO ()
fileAppendToAsync :: forall file.
FileClass file =>
file
-> [FileCreateFlags]
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileAppendToAsync file
file [FileCreateFlags]
flags Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
          (\(File ForeignPtr File
arg1) CInt
arg2 CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CInt
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_append_to_async Ptr File
argPtr1 CInt
arg2 CInt
arg3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 646 "./System/GIO/File/File.chs" #-}
            (file -> File
forall o. FileClass o => o -> File
toFile file
file)
            ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCreateFlags] -> Int) -> [FileCreateFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCreateFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCreateFlags]
flags)
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
            GAsyncReadyCallback
cCallback
            (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an asynchronous file append operation started with 'fileAppendToAsync'.
fileAppendToFinish :: FileClass file
                   => file
                   -> AsyncResult
                   -> IO FileOutputStream
fileAppendToFinish :: forall file.
FileClass file =>
file -> AsyncResult -> IO FileOutputStream
fileAppendToFinish file
file AsyncResult
asyncResult =
    (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
forall {a}.
(ForeignPtr FileOutputStream -> FileOutputStream, FinalizerPtr a)
mkFileOutputStream (IO (Ptr FileOutputStream) -> IO FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr AsyncResult -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File
-> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr FileOutputStream)
g_file_append_to_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Asynchronously creates a new file and returns an output stream for writing to it. The file must not
-- already exist.
--
-- For more details, see 'fileCreate' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call 'fileCreateFinish' to
-- get the result of the operation.
fileCreateAsync :: FileClass file
                  => file
                  -> [FileCreateFlags]
                  -> Int
                  -> Maybe Cancellable
                  -> AsyncReadyCallback
                  -> IO ()
fileCreateAsync :: forall file.
FileClass file =>
file
-> [FileCreateFlags]
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileCreateAsync file
file [FileCreateFlags]
flags Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
          (\(File ForeignPtr File
arg1) CInt
arg2 CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CInt
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_create_async Ptr File
argPtr1 CInt
arg2 CInt
arg3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 679 "./System/GIO/File/File.chs" #-}
            (file -> File
forall o. FileClass o => o -> File
toFile file
file)
            ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCreateFlags] -> Int) -> [FileCreateFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCreateFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCreateFlags]
flags)
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
            GAsyncReadyCallback
cCallback
            (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an asynchronous file create operation started with 'fileCreateAsync'.
fileCreateFinish :: FileClass file
                   => file
                   -> AsyncResult
                   -> IO FileOutputStream
fileCreateFinish :: forall file.
FileClass file =>
file -> AsyncResult -> IO FileOutputStream
fileCreateFinish file
file AsyncResult
asyncResult =
    (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
forall {a}.
(ForeignPtr FileOutputStream -> FileOutputStream, FinalizerPtr a)
mkFileOutputStream (IO (Ptr FileOutputStream) -> IO FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr AsyncResult -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File
-> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr FileOutputStream)
g_file_create_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the
-- file first.
--
-- For more details, see 'fileReplace' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call 'fileReplaceFinish'
-- to get the result of the operation.
fileReplaceAsync :: (FileClass file, GlibString string)
                 => file
                 -> string
                 -> Bool
                 -> [FileCreateFlags]
                 -> Int
                 -> Maybe Cancellable
                 -> AsyncReadyCallback
                 -> IO ()
fileReplaceAsync :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> Bool
-> [FileCreateFlags]
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileReplaceAsync file
file string
etag Bool
makeBackup [FileCreateFlags]
flags Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback =
        string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
etag ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
cEtag -> do
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
          (\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 CInt
arg4 CInt
arg5 (Cancellable ForeignPtr Cancellable
arg6) GAsyncReadyCallback
arg7 Ptr ()
arg8 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg6 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr6 ->Ptr File
-> CString
-> CInt
-> CInt
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_replace_async Ptr File
argPtr1 CString
arg2 CInt
arg3 CInt
arg4 CInt
arg5 Ptr Cancellable
argPtr6 GAsyncReadyCallback
arg7 Ptr ()
arg8)
{-# LINE 715 "./System/GIO/File/File.chs" #-}
            (file -> File
forall o. FileClass o => o -> File
toFile file
file)
            CString
cEtag
            (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
makeBackup)
            ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCreateFlags] -> Int) -> [FileCreateFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCreateFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCreateFlags]
flags)
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
            GAsyncReadyCallback
cCallback
            (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an asynchronous file replace operation started with 'fileReplaceAsync'.
fileReplaceFinish :: FileClass file
                  => file
                  -> AsyncResult
                  -> IO FileOutputStream
fileReplaceFinish :: forall file.
FileClass file =>
file -> AsyncResult -> IO FileOutputStream
fileReplaceFinish file
file AsyncResult
asyncResult =
    (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileOutputStream -> FileOutputStream,
 FinalizerPtr FileOutputStream)
forall {a}.
(ForeignPtr FileOutputStream -> FileOutputStream, FinalizerPtr a)
mkFileOutputStream (IO (Ptr FileOutputStream) -> IO FileOutputStream)
-> IO (Ptr FileOutputStream) -> IO FileOutputStream
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr File -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr FileOutputStream))
 -> IO (Ptr FileOutputStream))
-> (Ptr AsyncResult -> IO (Ptr FileOutputStream))
-> IO (Ptr FileOutputStream)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File
-> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr FileOutputStream)
g_file_replace_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Gets the requested information about specified file. The result is a 'FileInfo' object that contains
-- key-value attributes (such as the type or size of the file).
--
-- The attribute value is a string that specifies the file attributes that should be gathered. It is
-- not an error if it's not possible to read a particular requested attribute from a file - it just
-- won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The
-- wildcard \"*\" means all attributes, and a wildcard like \"standard::*\" means all attributes in the
-- standard namespace. An example attribute query be \"standard::*,'user'\". The standard attributes
-- are available as defines, like 'FileAttributeStandardName'.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- For symlinks, normally the information about the target of the symlink is returned, rather than
-- information about the symlink itself. However if you pass 'FileQueryInfoNofollowSymlinks' in
-- flags the information about the symlink itself will be returned. Also, for symlinks that point to
-- non-existing files the information about the symlink itself will be returned.
--
-- If the file does not exist, the 'IoErrorNotFound' error will be returned. Other errors are
-- possible too, and depend on what kind of filesystem the file is on.
fileQueryInfo :: (FileClass file, GlibString string)
              => file
              -> string
              -> [FileQueryInfoFlags]
              -> Maybe Cancellable
              -> IO FileInfo
fileQueryInfo :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> [FileQueryInfoFlags]
-> Maybe Cancellable
-> IO FileInfo
fileQueryInfo file
file string
attributes [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
forall {a}. (ForeignPtr FileInfo -> FileInfo, FinalizerPtr a)
mkFileInfo (IO (Ptr FileInfo) -> IO FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall a b. (a -> b) -> a -> b
$
        string -> (CString -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attributes ((CString -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (CString -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \CString
cAttributes ->
        (Ptr (Ptr ()) -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) Ptr (Ptr ())
arg5 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CString
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO (Ptr FileInfo)
g_file_query_info Ptr File
argPtr1 CString
arg2 CInt
arg3 Ptr Cancellable
argPtr4 Ptr (Ptr ())
arg5)
{-# LINE 764 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           CString
cAttributes
                           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        )

-- | Asynchronously gets the requested information about specified file. The result is a 'FileInfo' object
-- that contains key-value attributes (such as type or size for the file).
--
-- For more details, see 'fileQueryInfo' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileQueryInfoFinish' to get the result of the operation.
fileQueryInfoAsync :: (FileClass file, GlibString string)
                   => file
                   -> string
                   -> [FileQueryInfoFlags]
                   -> Int
                   -> Maybe Cancellable
                   -> AsyncReadyCallback
                   -> IO ()
fileQueryInfoAsync :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> [FileQueryInfoFlags]
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileQueryInfoAsync file
file string
attributes [FileQueryInfoFlags]
flags Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback =
        string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attributes ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
cAttributes -> do
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
          (\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) GAsyncReadyCallback
arg6 Ptr ()
arg7 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CInt
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_query_info_async Ptr File
argPtr1 CString
arg2 CInt
arg3 CInt
arg4 Ptr Cancellable
argPtr5 GAsyncReadyCallback
arg6 Ptr ()
arg7)
{-# LINE 789 "./System/GIO/File/File.chs" #-}
            (file -> File
forall o. FileClass o => o -> File
toFile file
file)
            CString
cAttributes
            ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
            GAsyncReadyCallback
cCallback
            (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an asynchronous file info query. See 'fileQueryInfoAsync'.
fileQueryInfoFinish :: FileClass file
                    => file
                    -> AsyncResult
                    -> IO FileInfo
fileQueryInfoFinish :: forall file. FileClass file => file -> AsyncResult -> IO FileInfo
fileQueryInfoFinish file
file AsyncResult
asyncResult =
    (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
forall {a}. (ForeignPtr FileInfo -> FileInfo, FinalizerPtr a)
mkFileInfo (IO (Ptr FileInfo) -> IO FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr AsyncResult -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr FileInfo)
g_file_query_info_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Utility function to check if a particular file exists. This is implemented using 'fileQueryInfo'
-- and as such does blocking I/O.
--
-- Note that in many cases it is racy to first check for file existence and then execute something
-- based on the outcome of that, because the file might have been created or removed in between the
-- operations. The general approach to handling that is to not check, but just do the operation and
-- handle the errors as they come.
--
-- As an example of race-free checking, take the case of reading a file, and if it doesn't exist,
-- creating it. There are two racy versions: read it, and on error create it; and: check if it exists,
-- if not create it. These can both result in two processes creating the file (with perhaps a partially
-- written file as the result). The correct approach is to always try to create the file with
-- 'fileCreate' which will either atomically create the file or fail with a 'IoErrorExists' error.
--
-- However, in many cases an existence check is useful in a user interface, for instance to make a menu
-- item sensitive/ insensitive, so that you don't have to fool users that something is possible and
-- then just show and error dialog. If you do this, you should make sure to also handle the errors that
-- can happen due to races when you execute the operation.
fileQueryExists :: FileClass file
                => file
                -> Maybe Cancellable
                -> Bool
fileQueryExists :: forall file. FileClass file => file -> Maybe Cancellable -> Bool
fileQueryExists file
file Maybe Cancellable
cancellable =
    IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> IO Bool -> Bool
forall a b. (a -> b) -> a -> b
$
    (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
              (\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File -> Ptr Cancellable -> IO CInt
g_file_query_exists Ptr File
argPtr1 Ptr Cancellable
argPtr2)
{-# LINE 832 "./System/GIO/File/File.chs" #-}
                (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)


-- | Utility function to inspect the 'FileType' of a file. This is implemented using 'fileQueryInfo'
-- and as such does blocking I/O.
--
-- The primary use case of this method is to check if a file is a regular file, directory, or symlink.
fileQueryFileType :: FileClass file
                    => file
                    -> [FileQueryInfoFlags]
                    -> Maybe Cancellable
                    -> FileType
fileQueryFileType :: forall file.
FileClass file =>
file -> [FileQueryInfoFlags] -> Maybe Cancellable -> FileType
fileQueryFileType file
file [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    (Int -> FileType
forall a. Enum a => Int -> a
toEnum (Int -> FileType) -> (CInt -> Int) -> CInt -> FileType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (CInt -> FileType) -> CInt -> FileType
forall a b. (a -> b) -> a -> b
$
    IO CInt -> CInt
forall a. IO a -> a
unsafePerformIO (IO CInt -> CInt) -> IO CInt -> CInt
forall a b. (a -> b) -> a -> b
$
        ((\(File ForeignPtr File
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File -> CInt -> Ptr Cancellable -> IO CInt
g_file_query_file_type Ptr File
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3)
{-# LINE 849 "./System/GIO/File/File.chs" #-}
           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable) )



-- | Similar to 'fileQueryInfo', but obtains information about the filesystem the file is on, rather
-- than the file itself. For instance the amount of space available and the type of the filesystem.
--
-- The attribute value is a string that specifies the file attributes that should be gathered. It is
-- not an error if it's not possible to read a particular requested attribute from a file - it just
-- won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The
-- wildcard \"*\" means all attributes, and a wildcard like "fs:*" means all attributes in the fs
-- namespace. The standard namespace for filesystem attributes is "fs". Common attributes of interest
-- are 'FILEAttributeFilesystemSize (The Total Size Of The Filesystem In Bytes)',
-- 'FILEAttributeFilesystemFree (Number Of Bytes Available)', and 'FileAttributeFilesystemType'
-- (type of the filesystem).
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- If the file does not exist, the 'IoErrorNotFound' error will be returned. Other errors are
-- possible too, and depend on what kind of filesystem the file is on.
fileQueryFilesystemInfo :: (FileClass file, GlibString string)
                        => file
                        -> string
                        -> Maybe Cancellable
                        -> IO FileInfo
fileQueryFilesystemInfo :: forall file string.
(FileClass file, GlibString string) =>
file -> string -> Maybe Cancellable -> IO FileInfo
fileQueryFilesystemInfo file
file string
attributes Maybe Cancellable
cancellable =
    (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
forall {a}. (ForeignPtr FileInfo -> FileInfo, FinalizerPtr a)
mkFileInfo (IO (Ptr FileInfo) -> IO FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall a b. (a -> b) -> a -> b
$
        string -> (CString -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attributes ((CString -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (CString -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \CString
cAttributes ->
        (Ptr (Ptr ()) -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CString
arg2 (Cancellable ForeignPtr Cancellable
arg3) Ptr (Ptr ())
arg4 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CString -> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr FileInfo)
g_file_query_filesystem_info Ptr File
argPtr1 CString
arg2 Ptr Cancellable
argPtr3 Ptr (Ptr ())
arg4)
{-# LINE 882 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           CString
cAttributes
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable) )

-- | Asynchronously gets the requested information about the filesystem that the specified file is
-- on. The result is a 'FileInfo' object that contains key-value attributes (such as type or size for
-- the file).
--
-- For more details, see 'fileQueryFilesystemInfo' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileQueryInfoFinish' to get the result of the operation.
fileQueryFilesystemInfoAsync :: (FileClass file, GlibString string)
                             => file
                             -> string
                             -> Int
                             -> Maybe Cancellable
                             -> AsyncReadyCallback
                             -> IO ()
fileQueryFilesystemInfoAsync :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileQueryFilesystemInfoAsync file
file string
attributes Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback =
        string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attributes ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
cAttributes -> do
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
          (\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CString
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_query_filesystem_info_async Ptr File
argPtr1 CString
arg2 CInt
arg3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 905 "./System/GIO/File/File.chs" #-}
            (file -> File
forall o. FileClass o => o -> File
toFile file
file)
            CString
cAttributes
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
            GAsyncReadyCallback
cCallback
            (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an asynchronous filesystem info query. See 'fileQueryFilesystemInfoAsync'.
fileQueryFilesystemInfoFinish :: FileClass file
                              => file
                              -> AsyncResult
                              -> IO FileInfo
fileQueryFilesystemInfoFinish :: forall file. FileClass file => file -> AsyncResult -> IO FileInfo
fileQueryFilesystemInfoFinish file
file AsyncResult
asyncResult =
    (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
forall {a}. (ForeignPtr FileInfo -> FileInfo, FinalizerPtr a)
mkFileInfo (IO (Ptr FileInfo) -> IO FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr File -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr AsyncResult -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr FileInfo)
g_file_query_filesystem_info_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Returns the 'AppInfo' that is registered as the default application to handle the file specified by
-- file.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileQueryDefaultHandler :: FileClass file
                        => file
                        -> Maybe Cancellable
                        -> IO AppInfo
fileQueryDefaultHandler :: forall file.
FileClass file =>
file -> Maybe Cancellable -> IO AppInfo
fileQueryDefaultHandler file
file Maybe Cancellable
cancellable =
    (ForeignPtr AppInfo -> AppInfo, FinalizerPtr AppInfo)
-> IO (Ptr AppInfo) -> IO AppInfo
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr AppInfo -> AppInfo, FinalizerPtr AppInfo)
forall {a}. (ForeignPtr AppInfo -> AppInfo, FinalizerPtr a)
mkAppInfo (IO (Ptr AppInfo) -> IO AppInfo) -> IO (Ptr AppInfo) -> IO AppInfo
forall a b. (a -> b) -> a -> b
$
        (Ptr (Ptr ()) -> IO (Ptr AppInfo)) -> IO (Ptr AppInfo)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr AppInfo)) -> IO (Ptr AppInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr AppInfo)) -> IO (Ptr AppInfo))
-> (Ptr File -> IO (Ptr AppInfo)) -> IO (Ptr AppInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr AppInfo)) -> IO (Ptr AppInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO (Ptr AppInfo)) -> IO (Ptr AppInfo))
-> (Ptr Cancellable -> IO (Ptr AppInfo)) -> IO (Ptr AppInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File -> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr AppInfo)
g_file_query_default_handler Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 934 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable) )

-- | Gets a 'Mount' for the 'File'.
--
-- If the 'FileIface' for file does not have a mount (e.g. possibly a remote share), error will be set
-- to 'IoErrorNotFound' and 'Nothing' will be returned.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileFindEnclosingMount :: FileClass file
                       => file
                       -> Maybe Cancellable
                       -> IO Mount
fileFindEnclosingMount :: forall file.
FileClass file =>
file -> Maybe Cancellable -> IO Mount
fileFindEnclosingMount file
file Maybe Cancellable
cancellable =
    (ForeignPtr Mount -> Mount, FinalizerPtr Mount)
-> IO (Ptr Mount) -> IO Mount
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr Mount -> Mount, FinalizerPtr Mount)
forall {a}. (ForeignPtr Mount -> Mount, FinalizerPtr a)
mkMount (IO (Ptr Mount) -> IO Mount) -> IO (Ptr Mount) -> IO Mount
forall a b. (a -> b) -> a -> b
$
        (Ptr (Ptr ()) -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr Mount)) -> IO (Ptr Mount))
-> (Ptr File -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO (Ptr Mount)) -> IO (Ptr Mount))
-> (Ptr Cancellable -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File -> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr Mount)
g_file_find_enclosing_mount Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 952 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        )

-- | Asynchronously gets the mount for the file.
--
-- For more details, see 'fileFindEnclosingMount' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileFindEnclosingMountFinish' to get the result of the operation.
fileFindEnclosingMountAsync :: FileClass file
                            => file
                            -> Int
                            -> Maybe Cancellable
                            -> AsyncReadyCallback
                            -> IO ()
fileFindEnclosingMountAsync :: forall file.
FileClass file =>
file -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO ()
fileFindEnclosingMountAsync file
file Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
          (\(File ForeignPtr File
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) GAsyncReadyCallback
arg4 Ptr ()
arg5 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_find_enclosing_mount_async Ptr File
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3 GAsyncReadyCallback
arg4 Ptr ()
arg5)
{-# LINE 971 "./System/GIO/File/File.chs" #-}
            (file -> File
forall o. FileClass o => o -> File
toFile file
file)
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
            GAsyncReadyCallback
cCallback
            (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an asynchronous find mount request. See 'fileFindEnclosingMountAsync'.
fileFindEnclosingMountFinish :: FileClass file
                             => file
                             -> AsyncResult
                             -> IO Mount
fileFindEnclosingMountFinish :: forall file. FileClass file => file -> AsyncResult -> IO Mount
fileFindEnclosingMountFinish file
file AsyncResult
asyncResult =
    (ForeignPtr Mount -> Mount, FinalizerPtr Mount)
-> IO (Ptr Mount) -> IO Mount
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr Mount -> Mount, FinalizerPtr Mount)
forall {a}. (ForeignPtr Mount -> Mount, FinalizerPtr a)
mkMount (IO (Ptr Mount) -> IO Mount) -> IO (Ptr Mount) -> IO Mount
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr Mount)) -> IO (Ptr Mount))
-> (Ptr File -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr Mount)) -> IO (Ptr Mount))
-> (Ptr AsyncResult -> IO (Ptr Mount)) -> IO (Ptr Mount)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr Mount)
g_file_find_enclosing_mount_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Gets the requested information about the files in a directory. The result is a 'FileEnumerator'
-- object that will give out 'FileInfo' objects for all the files in the directory.
--
-- The attribute value is a string that specifies the file attributes that should be gathered. It is
-- not an error if it's not possible to read a particular requested attribute from a file - it just
-- won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The
-- wildcard \"*\" means all attributes, and a wildcard like \"standard::*\" means all attributes in the
-- standard namespace. An example attribute query be \"standard::*,'user'\". The standard attributes
-- are available as defines, like 'FileAttributeStandardName'.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- If the file does not exist, the 'IoErrorNotFound' error will be returned. If the file is not a
-- directory, the 'FileErrorNotdir' error will be returned. Other errors are possible too.
fileEnumerateChildren :: FileClass file
                      => file
                      -> String
                      -> [FileQueryInfoFlags]
                      -> Maybe Cancellable
                      -> IO FileEnumerator
fileEnumerateChildren :: forall file.
FileClass file =>
file
-> String
-> [FileQueryInfoFlags]
-> Maybe Cancellable
-> IO FileEnumerator
fileEnumerateChildren file
file String
attributes [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    (ForeignPtr FileEnumerator -> FileEnumerator,
 FinalizerPtr FileEnumerator)
-> IO (Ptr FileEnumerator) -> IO FileEnumerator
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileEnumerator -> FileEnumerator,
 FinalizerPtr FileEnumerator)
forall {a}.
(ForeignPtr FileEnumerator -> FileEnumerator, FinalizerPtr a)
mkFileEnumerator (IO (Ptr FileEnumerator) -> IO FileEnumerator)
-> IO (Ptr FileEnumerator) -> IO FileEnumerator
forall a b. (a -> b) -> a -> b
$
        String
-> (CString -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator)
forall a. String -> (CString -> IO a) -> IO a
withCString String
attributes ((CString -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator))
-> (CString -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator)
forall a b. (a -> b) -> a -> b
$ \CString
cAttributes ->
        (Ptr (Ptr ()) -> IO (Ptr FileEnumerator))
-> IO (Ptr FileEnumerator)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) Ptr (Ptr ())
arg5 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator))
-> (Ptr File -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileEnumerator))
-> IO (Ptr FileEnumerator)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO (Ptr FileEnumerator))
 -> IO (Ptr FileEnumerator))
-> (Ptr Cancellable -> IO (Ptr FileEnumerator))
-> IO (Ptr FileEnumerator)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CString
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO (Ptr FileEnumerator)
g_file_enumerate_children Ptr File
argPtr1 CString
arg2 CInt
arg3 Ptr Cancellable
argPtr4 Ptr (Ptr ())
arg5)
{-# LINE 1012 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           CString
cAttributes
                           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        )

-- | Asynchronously gets the requested information about the files in a directory. The result is a
-- 'FileEnumerator' object that will give out 'FileInfo' objects for all the files in the directory.
--
-- For more details, see 'fileEnumerateChildren' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileEnumerateChildrenFinish' to get the result of the operation.
fileEnumerateChildrenAsync :: (FileClass file, GlibString string)
                           => file
                           -> string
                           -> [FileQueryInfoFlags]
                           -> Int
                           -> Maybe Cancellable
                           -> AsyncReadyCallback
                           -> IO ()
fileEnumerateChildrenAsync :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> [FileQueryInfoFlags]
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileEnumerateChildrenAsync file
file string
attributes [FileQueryInfoFlags]
flags Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback =
        string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attributes ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
cAttributes -> do
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
          (\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) GAsyncReadyCallback
arg6 Ptr ()
arg7 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CInt
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_enumerate_children_async Ptr File
argPtr1 CString
arg2 CInt
arg3 CInt
arg4 Ptr Cancellable
argPtr5 GAsyncReadyCallback
arg6 Ptr ()
arg7)
{-# LINE 1037 "./System/GIO/File/File.chs" #-}
            (file -> File
forall o. FileClass o => o -> File
toFile file
file)
            CString
cAttributes
            ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
            GAsyncReadyCallback
cCallback
            (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an async enumerate children operation. See 'fileEnumerateChildrenAsync'.
fileEnumerateChildrenFinish :: FileClass file
                             => file
                             -> AsyncResult
                             -> IO FileEnumerator
fileEnumerateChildrenFinish :: forall file.
FileClass file =>
file -> AsyncResult -> IO FileEnumerator
fileEnumerateChildrenFinish file
file AsyncResult
asyncResult =
    (ForeignPtr FileEnumerator -> FileEnumerator,
 FinalizerPtr FileEnumerator)
-> IO (Ptr FileEnumerator) -> IO FileEnumerator
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileEnumerator -> FileEnumerator,
 FinalizerPtr FileEnumerator)
forall {a}.
(ForeignPtr FileEnumerator -> FileEnumerator, FinalizerPtr a)
mkFileEnumerator (IO (Ptr FileEnumerator) -> IO FileEnumerator)
-> IO (Ptr FileEnumerator) -> IO FileEnumerator
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr FileEnumerator))
-> IO (Ptr FileEnumerator)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator))
-> (Ptr File -> IO (Ptr FileEnumerator)) -> IO (Ptr FileEnumerator)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr FileEnumerator))
-> IO (Ptr FileEnumerator)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr FileEnumerator))
 -> IO (Ptr FileEnumerator))
-> (Ptr AsyncResult -> IO (Ptr FileEnumerator))
-> IO (Ptr FileEnumerator)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File
-> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr FileEnumerator)
g_file_enumerate_children_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Renames file to the specified display name.
--
-- The display name is converted from UTF8 to the correct encoding for the target filesystem if
-- possible and the file is renamed to this.
--
-- If you want to implement a rename operation in the user interface the edit name
-- ('FileAttributeStandardEditName') should be used as the initial value in the rename widget, and
-- then the result after editing should be passed to 'fileSetDisplayName'.
--
-- On success the resulting converted filename is returned.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileSetDisplayName :: (FileClass file, GlibString string)
                   => file
                   -> string
                   -> Maybe Cancellable
                   -> IO File
fileSetDisplayName :: forall file string.
(FileClass file, GlibString string) =>
file -> string -> Maybe Cancellable -> IO File
fileSetDisplayName file
file string
displayName Maybe Cancellable
cancellable =
    (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
        string -> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
displayName ((CString -> IO (Ptr File)) -> IO (Ptr File))
-> (CString -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \CString
cDisplayName ->
        (Ptr (Ptr ()) -> IO (Ptr File)) -> IO (Ptr File)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CString
arg2 (Cancellable ForeignPtr Cancellable
arg3) Ptr (Ptr ())
arg4 -> ForeignPtr File -> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr Cancellable -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CString -> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr File)
g_file_set_display_name Ptr File
argPtr1 CString
arg2 Ptr Cancellable
argPtr3 Ptr (Ptr ())
arg4)
{-# LINE 1077 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           CString
cDisplayName
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable) )

-- | Asynchronously sets the display name for a given 'File'.
--
-- For more details, see 'fileSetDisplayName' which is the synchronous version of this call.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileSetDisplayNameFinish' to get the result of the operation.
fileSetDisplayNameAsync :: (FileClass file, GlibString string)
                        => file
                        -> string
                        -> Int
                        -> Maybe Cancellable
                        -> AsyncReadyCallback
                        -> IO ()
fileSetDisplayNameAsync :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileSetDisplayNameAsync file
file string
displayName Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback =
        string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
displayName ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
cDisplayName -> do
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
          (\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CString
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_set_display_name_async Ptr File
argPtr1 CString
arg2 CInt
arg3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 1098 "./System/GIO/File/File.chs" #-}
             (file -> File
forall o. FileClass o => o -> File
toFile file
file)
             CString
cDisplayName
             (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
             (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
             GAsyncReadyCallback
cCallback
             (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes setting a display name started with 'fileSetDisplayNameAsync'.
fileSetDisplayNameFinish :: FileClass file
                         => file
                         -> AsyncResult
                         -> IO File
fileSetDisplayNameFinish :: forall file. FileClass file => file -> AsyncResult -> IO File
fileSetDisplayNameFinish file
file AsyncResult
asyncResult =
    (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr File)) -> IO (Ptr File)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr AsyncResult -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr File)
g_file_set_display_name_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
asyncResult)

-- | Deletes a file. If the file is a directory, it will only be deleted if it is empty.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileDelete :: FileClass file
           => file
           -> Maybe Cancellable
           -> IO ()
fileDelete :: forall file. FileClass file => file -> Maybe Cancellable -> IO ()
fileDelete file
file Maybe Cancellable
cancellable =
        (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File -> Ptr Cancellable -> Ptr (Ptr ()) -> IO CInt
g_file_delete Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1125 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        ) IO CInt -> IO () -> IO ()
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- | Sends file to the "Trashcan", if possible. This is similar to deleting it, but the user can recover
-- it before emptying the trashcan. Not all file systems support trashing, so this call can return the
-- 'IoErrorNotSupported' error.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileTrash :: FileClass file
           => file
           -> Maybe Cancellable
           -> IO ()
fileTrash :: forall file. FileClass file => file -> Maybe Cancellable -> IO ()
fileTrash file
file Maybe Cancellable
cancellable =
        (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File -> Ptr Cancellable -> Ptr (Ptr ()) -> IO CInt
g_file_trash Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1142 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        ) IO CInt -> IO () -> IO ()
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- | Copies the file source to the location specified by destination. Can not handle recursive copies of
-- directories.
--
-- If the flag 'FileCopyOverwrite' is specified an already existing destination file is overwritten.
--
-- If the flag 'FileCopyNofollowSymlinks' is specified then symlinks will be copied as symlinks,
-- otherwise the target of the source symlink will be copied.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- If @progressCallback@ is not 'Nothing', then the operation can be monitored by setting this to a
-- 'FileProgressCallback' function. @progressCallbackData@ will be passed to this function. It is
-- guaranteed that this callback will be called after all data has been transferred with the total
-- number of bytes copied during the operation.
--
-- If the source file does not exist then the 'IoErrorNotFound' error is returned, independent on
-- the status of the destination.
--
-- If 'FileCopyOverwrite' is not specified and the target exists, then the error 'IoErrorExists' is
-- returned.
--
-- If trying to overwrite a file over a directory the 'IoErrorIsDirectory' error is returned. If
-- trying to overwrite a directory with a directory the 'IoErrorWouldMerge' error is returned.
--
-- If the source is a directory and the target does not exist, or 'FileCopyOverwrite' is specified
-- and the target is a file, then the 'IoErrorWouldRecurse' error is returned.
--
-- If you are interested in copying the 'File' object itself (not the on-disk file), see 'fileDup'.
fileCopy :: (FileClass source, FileClass destination)
         => source
         -> destination
         -> [FileCopyFlags]
         -> Maybe Cancellable
         -> Maybe FileProgressCallback
         -> IO ()
fileCopy :: forall source destination.
(FileClass source, FileClass destination) =>
source
-> destination
-> [FileCopyFlags]
-> Maybe Cancellable
-> Maybe FileProgressCallback
-> IO ()
fileCopy source
source destination
destination [FileCopyFlags]
flags Maybe Cancellable
cancellable Maybe FileProgressCallback
progressCallback = do
          GFileProgressCallback
cProgressCallback <- IO GFileProgressCallback
-> (FileProgressCallback -> IO GFileProgressCallback)
-> Maybe FileProgressCallback
-> IO GFileProgressCallback
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (GFileProgressCallback -> IO GFileProgressCallback
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GFileProgressCallback
forall a. FunPtr a
nullFunPtr) FileProgressCallback -> IO GFileProgressCallback
marshalFileProgressCallback Maybe FileProgressCallback
progressCallback
          (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((Ptr (Ptr ()) -> IO ()) -> IO ())
-> (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
cError -> do
            (\(File ForeignPtr File
arg1) (File ForeignPtr File
arg2) CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) GFileProgressCallback
arg5 Ptr ()
arg6 Ptr (Ptr ())
arg7 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg2 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr2 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> Ptr File
-> CInt
-> Ptr Cancellable
-> GFileProgressCallback
-> Ptr ()
-> Ptr (Ptr ())
-> IO CInt
g_file_copy Ptr File
argPtr1 Ptr File
argPtr2 CInt
arg3 Ptr Cancellable
argPtr4 GFileProgressCallback
arg5 Ptr ()
arg6 Ptr (Ptr ())
arg7)
{-# LINE 1187 "./System/GIO/File/File.chs" #-}
                      (source -> File
forall o. FileClass o => o -> File
toFile source
source)
                      (destination -> File
forall o. FileClass o => o -> File
toFile destination
destination)
                      ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCopyFlags] -> Int) -> [FileCopyFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCopyFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCopyFlags]
flags)
                      (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                      GFileProgressCallback
cProgressCallback
                      Ptr ()
forall a. Ptr a
nullPtr
                      Ptr (Ptr ())
cError
            Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (GFileProgressCallback
cProgressCallback GFileProgressCallback -> GFileProgressCallback -> Bool
forall a. Eq a => a -> a -> Bool
/= GFileProgressCallback
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
              GFileProgressCallback -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr GFileProgressCallback
cProgressCallback

-- | Copies the file source to the location specified by destination asynchronously. For details of the
-- behaviour, see 'fileCopy'.
--
-- If @progressCallback@ is not 'Nothing', then that function that will be called just like in 'fileCopy',
-- however the callback will run in the main loop, not in the thread that is doing the I/O operation.
--
-- When the operation is finished, callback will be called. You can then call 'fileCopyFinish' to
-- get the result of the operation.
fileCopyAsync :: (FileClass source, FileClass destination)
              => source
              -> destination
              -> [FileCopyFlags]
              -> Int
              -> Maybe Cancellable
              -> Maybe FileProgressCallback
              -> AsyncReadyCallback
              -> IO ()
fileCopyAsync :: forall source destination.
(FileClass source, FileClass destination) =>
source
-> destination
-> [FileCopyFlags]
-> Int
-> Maybe Cancellable
-> Maybe FileProgressCallback
-> AsyncReadyCallback
-> IO ()
fileCopyAsync source
source destination
destination [FileCopyFlags]
flags Int
ioPriority Maybe Cancellable
cancellable Maybe FileProgressCallback
progressCallback AsyncReadyCallback
callback = do
          GFileProgressCallback
cProgressCallback <- IO GFileProgressCallback
-> (FileProgressCallback -> IO GFileProgressCallback)
-> Maybe FileProgressCallback
-> IO GFileProgressCallback
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (GFileProgressCallback -> IO GFileProgressCallback
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GFileProgressCallback
forall a. FunPtr a
nullFunPtr) FileProgressCallback -> IO GFileProgressCallback
marshalFileProgressCallback Maybe FileProgressCallback
progressCallback
          GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback (AsyncReadyCallback -> IO GAsyncReadyCallback)
-> AsyncReadyCallback -> IO GAsyncReadyCallback
forall a b. (a -> b) -> a -> b
$ \GObject
sourceObject AsyncResult
res -> do
                         Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (GFileProgressCallback
cProgressCallback GFileProgressCallback -> GFileProgressCallback -> Bool
forall a. Eq a => a -> a -> Bool
/= GFileProgressCallback
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
                           GFileProgressCallback -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr GFileProgressCallback
cProgressCallback
                         AsyncReadyCallback
callback GObject
sourceObject AsyncResult
res
          (\(File ForeignPtr File
arg1) (File ForeignPtr File
arg2) CInt
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) GFileProgressCallback
arg6 Ptr ()
arg7 GAsyncReadyCallback
arg8 Ptr ()
arg9 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg2 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr2 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> Ptr File
-> CInt
-> CInt
-> Ptr Cancellable
-> GFileProgressCallback
-> Ptr ()
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_copy_async Ptr File
argPtr1 Ptr File
argPtr2 CInt
arg3 CInt
arg4 Ptr Cancellable
argPtr5 GFileProgressCallback
arg6 Ptr ()
arg7 GAsyncReadyCallback
arg8 Ptr ()
arg9)
{-# LINE 1221 "./System/GIO/File/File.chs" #-}
            (source -> File
forall o. FileClass o => o -> File
toFile source
source)
            (destination -> File
forall o. FileClass o => o -> File
toFile destination
destination)
            ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCopyFlags] -> Int) -> [FileCopyFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCopyFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCopyFlags]
flags)
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
            GFileProgressCallback
cProgressCallback
            Ptr ()
forall a. Ptr a
nullPtr
            GAsyncReadyCallback
cCallback
            (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes copying the file started with 'fileCopyAsync'.
--
-- Throws a 'GError' if an error occurs.
fileCopyFinish :: FileClass file
               => file
               -> AsyncResult
               -> IO ()
fileCopyFinish :: forall file. FileClass file => file -> AsyncResult -> IO ()
fileCopyFinish file
file AsyncResult
asyncResult =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_file_copy_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1241 "./System/GIO/File/File.chs" #-}
                         (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                         AsyncResult
asyncResult
                         Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Tries to move the file or directory source to the location specified by destination. If native move
-- operations are supported then this is used, otherwise a copy + delete fallback is used. The native
-- implementation may support moving directories (for instance on moves inside the same filesystem),
-- but the fallback code does not.
--
-- If the flag 'FileCopyOverwrite' is specified an already existing destination file is overwritten.
--
-- If the flag 'FileCopyNofollowSymlinks' is specified then symlinks will be copied as symlinks,
-- otherwise the target of the source symlink will be copied.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- If @progressCallback@ is not 'Nothing', then the operation can be monitored by setting this to a
-- 'FileProgressCallback' function. @progressCallbackData@ will be passed to this function. It is
-- guaranteed that this callback will be called after all data has been transferred with the total
-- number of bytes copied during the operation.
--
-- If the source file does not exist then the 'IoErrorNotFound' error is returned, independent on
-- the status of the destination.
--
-- If 'FileCopyOverwrite' is not specified and the target exists, then the error 'IoErrorExists' is
-- returned.
--
-- If trying to overwrite a file over a directory the 'IoErrorIsDirectory' error is returned. If
-- trying to overwrite a directory with a directory the 'IoErrorWouldMerge' error is returned.
--
-- If the source is a directory and the target does not exist, or 'FileCopyOverwrite' is specified
-- and the target is a file, then the 'IoErrorWouldRecurse' error may be returned (if the native
-- move operation isn't available).
fileMove :: (FileClass source, FileClass destination)
         => source
         -> destination
         -> [FileCopyFlags]
         -> Maybe Cancellable
         -> Maybe FileProgressCallback
         -> IO ()
fileMove :: forall source destination.
(FileClass source, FileClass destination) =>
source
-> destination
-> [FileCopyFlags]
-> Maybe Cancellable
-> Maybe FileProgressCallback
-> IO ()
fileMove source
source destination
destination [FileCopyFlags]
flags Maybe Cancellable
cancellable Maybe FileProgressCallback
progressCallback = do
          GFileProgressCallback
cProgressCallback <- IO GFileProgressCallback
-> (FileProgressCallback -> IO GFileProgressCallback)
-> Maybe FileProgressCallback
-> IO GFileProgressCallback
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (GFileProgressCallback -> IO GFileProgressCallback
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GFileProgressCallback
forall a. FunPtr a
nullFunPtr) FileProgressCallback -> IO GFileProgressCallback
marshalFileProgressCallback Maybe FileProgressCallback
progressCallback
          (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((Ptr (Ptr ()) -> IO ()) -> IO ())
-> (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
cError -> do
            (\(File ForeignPtr File
arg1) (File ForeignPtr File
arg2) CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) GFileProgressCallback
arg5 Ptr ()
arg6 Ptr (Ptr ())
arg7 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg2 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr2 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> Ptr File
-> CInt
-> Ptr Cancellable
-> GFileProgressCallback
-> Ptr ()
-> Ptr (Ptr ())
-> IO CInt
g_file_move Ptr File
argPtr1 Ptr File
argPtr2 CInt
arg3 Ptr Cancellable
argPtr4 GFileProgressCallback
arg5 Ptr ()
arg6 Ptr (Ptr ())
arg7)
{-# LINE 1288 "./System/GIO/File/File.chs" #-}
                    (source -> File
forall o. FileClass o => o -> File
toFile source
source)
                    (destination -> File
forall o. FileClass o => o -> File
toFile destination
destination)
                    ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCopyFlags] -> Int) -> [FileCopyFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCopyFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCopyFlags]
flags)
                    (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                    GFileProgressCallback
cProgressCallback
                    Ptr ()
forall a. Ptr a
nullPtr
                    Ptr (Ptr ())
cError
            Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (GFileProgressCallback
cProgressCallback GFileProgressCallback -> GFileProgressCallback -> Bool
forall a. Eq a => a -> a -> Bool
/= GFileProgressCallback
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
              GFileProgressCallback -> IO ()
forall a. FunPtr a -> IO ()
freeHaskellFunPtr GFileProgressCallback
cProgressCallback

-- | Creates a directory. Note that this will only create a child directory of the immediate parent
-- directory of the path or URI given by the 'File'. To recursively create directories, see
-- 'fileMakeDirectoryWithParents'. This function will fail if the parent directory does not
-- exist, setting error to 'IoErrorNotFound'. If the file system doesn't support creating
-- directories, this function will fail, setting error to 'IoErrorNotSupported'.
--
-- For a local 'File' the newly created directory will have the default (current) ownership and
-- permissions of the current process.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileMakeDirectory :: FileClass file
                  => file
                  -> Maybe Cancellable
                  -> IO ()
fileMakeDirectory :: forall file. FileClass file => file -> Maybe Cancellable -> IO ()
fileMakeDirectory file
file Maybe Cancellable
cancellable = do
          (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((Ptr (Ptr ()) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File -> Ptr Cancellable -> Ptr (Ptr ()) -> IO CInt
g_file_make_directory Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1316 "./System/GIO/File/File.chs" #-}
                              (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                              (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- | Creates a directory and any parent directories that may not exist similar to 'mkdir -p'. If the file
-- system does not support creating directories, this function will fail, setting error to
-- 'IoErrorNotSupported'.
--
-- For a local 'File' the newly created directories will have the default (current) ownership and
-- permissions of the current process.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileMakeDirectoryWithParents :: FileClass file
                             => file
                             -> Maybe Cancellable
                             -> IO ()
fileMakeDirectoryWithParents :: forall file. FileClass file => file -> Maybe Cancellable -> IO ()
fileMakeDirectoryWithParents file
file Maybe Cancellable
cancellable = do
          (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((Ptr (Ptr ()) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File -> Ptr Cancellable -> Ptr (Ptr ()) -> IO CInt
g_file_make_directory_with_parents Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1337 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- | Creates a symbolic link.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileMakeSymbolicLink :: FileClass file
                     => file
                     -> ByteString
                     -> Maybe Cancellable
                     -> IO ()
fileMakeSymbolicLink :: forall file.
FileClass file =>
file -> ByteString -> Maybe Cancellable -> IO ()
fileMakeSymbolicLink file
file ByteString
symlinkValue Maybe Cancellable
cancellable =
        ByteString -> (CString -> IO ()) -> IO ()
forall a. ByteString -> (CString -> IO a) -> IO a
useAsCString ByteString
symlinkValue ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
cSymlinkValue -> do
          (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((Ptr (Ptr ()) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ (\(File ForeignPtr File
arg1) CString
arg2 (Cancellable ForeignPtr Cancellable
arg3) Ptr (Ptr ())
arg4 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File -> CString -> Ptr Cancellable -> Ptr (Ptr ()) -> IO CInt
g_file_make_symbolic_link Ptr File
argPtr1 CString
arg2 Ptr Cancellable
argPtr3 Ptr (Ptr ())
arg4)
{-# LINE 1355 "./System/GIO/File/File.chs" #-}
                              (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                              CString
cSymlinkValue
                              (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

newtype FileAttributeInfoList = FileAttributeInfoList (Ptr (FileAttributeInfoList))
{-# LINE 1361 "./System/GIO/File/File.chs" #-}
takeFileAttributeInfoList :: Ptr FileAttributeInfoList
                          -> IO [FileAttributeInfo]
takeFileAttributeInfoList :: Ptr FileAttributeInfoList -> IO [FileAttributeInfo]
takeFileAttributeInfoList Ptr FileAttributeInfoList
ptr =
    do Ptr FileAttributeInfo
cInfos <- (Ptr () -> Ptr FileAttributeInfo)
-> IO (Ptr ()) -> IO (Ptr FileAttributeInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Ptr () -> Ptr FileAttributeInfo
forall a b. Ptr a -> Ptr b
castPtr (IO (Ptr ()) -> IO (Ptr FileAttributeInfo))
-> IO (Ptr ()) -> IO (Ptr FileAttributeInfo)
forall a b. (a -> b) -> a -> b
$ (\Ptr FileAttributeInfoList
ptr -> do {Ptr FileAttributeInfoList -> Int -> IO (Ptr ())
forall b. Ptr b -> Int -> IO (Ptr ())
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr FileAttributeInfoList
ptr Int
0 ::IO (Ptr ())}) Ptr FileAttributeInfoList
ptr
       CInt
cNInfos <- (\Ptr FileAttributeInfoList
ptr -> do {Ptr FileAttributeInfoList -> Int -> IO CInt
forall b. Ptr b -> Int -> IO CInt
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr FileAttributeInfoList
ptr Int
8 ::IO CInt}) Ptr FileAttributeInfoList
ptr
       [FileAttributeInfo]
infos <- Int -> Ptr FileAttributeInfo -> IO [FileAttributeInfo]
forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
cNInfos) Ptr FileAttributeInfo
cInfos
       [FileAttributeInfo] -> IO [FileAttributeInfo]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [FileAttributeInfo]
infos

-- | Obtain the list of settable attributes for the file.
--
-- Returns the type and full attribute name of all the attributes that can be set on this file. This
-- doesn't mean setting it will always succeed though, you might get an access failure, or some
-- specific file may not support a specific attribute.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileQuerySettableAttributes :: FileClass file
                            => file
                            -> Maybe Cancellable
                            -> IO [FileAttributeInfo]
fileQuerySettableAttributes :: forall file.
FileClass file =>
file -> Maybe Cancellable -> IO [FileAttributeInfo]
fileQuerySettableAttributes file
file Maybe Cancellable
cancellable = do
          Ptr FileAttributeInfoList
ptr <- (Ptr (Ptr ()) -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((Ptr (Ptr ()) -> IO (Ptr FileAttributeInfoList))
 -> IO (Ptr FileAttributeInfoList))
-> (Ptr (Ptr ()) -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. (a -> b) -> a -> b
$
                (\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileAttributeInfoList))
 -> IO (Ptr FileAttributeInfoList))
-> (Ptr File -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO (Ptr FileAttributeInfoList))
 -> IO (Ptr FileAttributeInfoList))
-> (Ptr Cancellable -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO (Ptr FileAttributeInfoList)
g_file_query_settable_attributes Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1385 "./System/GIO/File/File.chs" #-}
                   (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                   (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          [FileAttributeInfo]
infos <- Ptr FileAttributeInfoList -> IO [FileAttributeInfo]
takeFileAttributeInfoList Ptr FileAttributeInfoList
ptr
          [FileAttributeInfo] -> IO [FileAttributeInfo]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [FileAttributeInfo]
infos

-- | Obtain the list of attribute namespaces where new attributes can be created by a user. An example of
-- this is extended attributes (in the "xattr" namespace).
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileQueryWritableNamespaces :: FileClass file
                            => file
                            -> Maybe Cancellable
                            -> IO [FileAttributeInfo]
fileQueryWritableNamespaces :: forall file.
FileClass file =>
file -> Maybe Cancellable -> IO [FileAttributeInfo]
fileQueryWritableNamespaces file
file Maybe Cancellable
cancellable = do
          Ptr FileAttributeInfoList
ptr <- (Ptr (Ptr ()) -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((Ptr (Ptr ()) -> IO (Ptr FileAttributeInfoList))
 -> IO (Ptr FileAttributeInfoList))
-> (Ptr (Ptr ()) -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. (a -> b) -> a -> b
$
                (\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileAttributeInfoList))
 -> IO (Ptr FileAttributeInfoList))
-> (Ptr File -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO (Ptr FileAttributeInfoList))
 -> IO (Ptr FileAttributeInfoList))
-> (Ptr Cancellable -> IO (Ptr FileAttributeInfoList))
-> IO (Ptr FileAttributeInfoList)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO (Ptr FileAttributeInfoList)
g_file_query_writable_namespaces Ptr File
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1403 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          [FileAttributeInfo]
infos <- Ptr FileAttributeInfoList -> IO [FileAttributeInfo]
takeFileAttributeInfoList Ptr FileAttributeInfoList
ptr
          [FileAttributeInfo] -> IO [FileAttributeInfo]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [FileAttributeInfo]
infos

-- | Tries to set all attributes in the 'FileInfo' on the target values, not stopping on the first error.
--
-- If there is any error during this operation then error will be set to the first error. Error on
-- particular fields are flagged by setting the "status" field in the attribute value to
-- 'FileAttributeStatusErrorSetting', which means you can also detect further errors.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileSetAttributesFromInfo :: FileClass file => file
 -> FileInfo
 -> [FileQueryInfoFlags]
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileSetAttributesFromInfo :: forall file.
FileClass file =>
file
-> FileInfo -> [FileQueryInfoFlags] -> Maybe Cancellable -> IO ()
fileSetAttributesFromInfo file
file FileInfo
fileInfo [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(File ForeignPtr File
arg1) (FileInfo ForeignPtr FileInfo
arg2) CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) Ptr (Ptr ())
arg5 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr FileInfo -> (Ptr FileInfo -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileInfo
arg2 ((Ptr FileInfo -> IO CInt) -> IO CInt)
-> (Ptr FileInfo -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr FileInfo
argPtr2 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> Ptr FileInfo
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO CInt
g_file_set_attributes_from_info Ptr File
argPtr1 Ptr FileInfo
argPtr2 CInt
arg3 Ptr Cancellable
argPtr4 Ptr (Ptr ())
arg5)
{-# LINE 1425 "./System/GIO/File/File.chs" #-}
                            (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                            (FileInfo -> FileInfo
forall o. FileInfoClass o => o -> FileInfo
toFileInfo FileInfo
fileInfo)
                            ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                            Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Asynchronously sets the attributes of file with info.
--
-- For more details, see 'fileSetAttributesFromInfo' which is the synchronous version of this
-- call.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileSetAttributesFinish' to get the result of the operation.
fileSetAttributesFromInfoAsync :: FileClass file => file
 -> FileInfo
 -> [FileQueryInfoFlags]
 -> Int -- ^ @ioPriority@ the I/O priority of the request.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback
 -> IO () -- ^ returns 'True' if there was any error, 'False' otherwise.
fileSetAttributesFromInfoAsync :: forall file.
FileClass file =>
file
-> FileInfo
-> [FileQueryInfoFlags]
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileSetAttributesFromInfoAsync file
file FileInfo
fileInfo [FileQueryInfoFlags]
flags Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
            GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
            (\(File ForeignPtr File
arg1) (FileInfo ForeignPtr FileInfo
arg2) CInt
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) GAsyncReadyCallback
arg6 Ptr ()
arg7 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr FileInfo -> (Ptr FileInfo -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileInfo
arg2 ((Ptr FileInfo -> IO ()) -> IO ())
-> (Ptr FileInfo -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileInfo
argPtr2 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> Ptr FileInfo
-> CInt
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_set_attributes_async Ptr File
argPtr1 Ptr FileInfo
argPtr2 CInt
arg3 CInt
arg4 Ptr Cancellable
argPtr5 GAsyncReadyCallback
arg6 Ptr ()
arg7)
{-# LINE 1449 "./System/GIO/File/File.chs" #-}
              (file -> File
forall o. FileClass o => o -> File
toFile file
file)
              (FileInfo -> FileInfo
forall o. FileInfoClass o => o -> FileInfo
toFileInfo FileInfo
fileInfo)
              ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
              (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
              (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
              GAsyncReadyCallback
cCallback
              (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes setting an attribute started in 'fileSetAttributesAsync'.
--
-- Throws a 'GError' if an error occurs.
fileSetAttributesFinish :: FileClass file
 => file
 -> AsyncResult
 -> FileInfo
 -> IO ()
fileSetAttributesFinish :: forall file.
FileClass file =>
file -> AsyncResult -> FileInfo -> IO ()
fileSetAttributesFinish file
file AsyncResult
asyncResult FileInfo
fileInfo =
    ForeignPtr FileInfo -> (Ptr FileInfo -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr (FileInfo -> ForeignPtr FileInfo
unFileInfo FileInfo
fileInfo) ((Ptr FileInfo -> IO ()) -> IO ())
-> (Ptr FileInfo -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileInfo
cFileInfo ->
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr FileInfo
arg3 Ptr (Ptr ())
arg4 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File
-> Ptr AsyncResult -> Ptr FileInfo -> Ptr (Ptr ()) -> IO CInt
g_file_set_attributes_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr FileInfo
arg3 Ptr (Ptr ())
arg4)
{-# LINE 1469 "./System/GIO/File/File.chs" #-}
                        (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                        AsyncResult
asyncResult
                        Ptr FileInfo
cFileInfo
                        Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Sets attribute of type 'FileAttributeTypeString' to value. If attribute is of a different type,
-- this operation will fail.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileSetAttributeString :: (FileClass file, GlibString string) => file
 -> string -- ^ @attribute@ a string containing the attribute's name.
 -> string -- ^ @value@ a string containing the attribute's value.
 -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileSetAttributeString :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> string
-> [FileQueryInfoFlags]
-> Maybe Cancellable
-> IO ()
fileSetAttributeString file
file string
attribute string
value [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attribute ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ CString
attributePtr ->
    string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
value ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ CString
valuePtr -> do
            (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                               (\(File ForeignPtr File
arg1) CString
arg2 CString
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) Ptr (Ptr ())
arg6 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CString
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO CInt
g_file_set_attribute_string Ptr File
argPtr1 CString
arg2 CString
arg3 CInt
arg4 Ptr Cancellable
argPtr5 Ptr (Ptr ())
arg6)
{-# LINE 1492 "./System/GIO/File/File.chs" #-}
                                   (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                                   CString
attributePtr
                                   CString
valuePtr
                                   ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                                   (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                                   Ptr (Ptr ())
gErrorPtr
                               () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Sets attribute of type 'FileAttributeTypeByteString' to value. If attribute is of a different
-- type, this operation will fail, returning 'False'.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileSetAttributeByteString :: (FileClass file, GlibString string) => file
 -> string -- ^ @attribute@ a string containing the attribute's name.
 -> string -- ^ @value@ a string containing the attribute's value.
 -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileSetAttributeByteString :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> string
-> [FileQueryInfoFlags]
-> Maybe Cancellable
-> IO ()
fileSetAttributeByteString file
file string
attribute string
value [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attribute ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ CString
attributePtr ->
    string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
value ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ CString
valuePtr -> do
            (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                                (\(File ForeignPtr File
arg1) CString
arg2 CString
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) Ptr (Ptr ())
arg6 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CString
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO CInt
g_file_set_attribute_byte_string Ptr File
argPtr1 CString
arg2 CString
arg3 CInt
arg4 Ptr Cancellable
argPtr5 Ptr (Ptr ())
arg6)
{-# LINE 1517 "./System/GIO/File/File.chs" #-}
                                   (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                                   CString
attributePtr
                                   CString
valuePtr
                                   ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                                   (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                                   Ptr (Ptr ())
gErrorPtr
                                () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Sets attribute of type 'FileAttributeTypeUint32' to value. If attribute is of a different type,
-- this operation will fail.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileSetAttributeWord32 :: (FileClass file, GlibString string) => file
 -> string -- ^ @attribute@ a string containing the attribute's name.
 -> Word32 -- ^ @value@ a Word32 containing the attribute's new value.
 -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileSetAttributeWord32 :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> Word32
-> [FileQueryInfoFlags]
-> Maybe Cancellable
-> IO ()
fileSetAttributeWord32 file
file string
attribute Word32
value [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attribute ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ CString
attributePtr ->
            (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                                (\(File ForeignPtr File
arg1) CString
arg2 CUInt
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) Ptr (Ptr ())
arg6 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CUInt
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO CInt
g_file_set_attribute_uint32 Ptr File
argPtr1 CString
arg2 CUInt
arg3 CInt
arg4 Ptr Cancellable
argPtr5 Ptr (Ptr ())
arg6)
{-# LINE 1541 "./System/GIO/File/File.chs" #-}
                                  (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                                  CString
attributePtr
                                  (Word32 -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
value)
                                  ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                                  (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                                  Ptr (Ptr ())
gErrorPtr
                                () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Sets attribute of type 'FileAttributeTypeInt32' to value. If attribute is of a different type,
-- this operation will fail.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileSetAttributeInt32 :: (FileClass file, GlibString string) => file
 -> string -- ^ @attribute@ a string containing the attribute's name.
 -> Int32 -- ^ @value@ a Int32 containing the attribute's new value.
 -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileSetAttributeInt32 :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> Int32
-> [FileQueryInfoFlags]
-> Maybe Cancellable
-> IO ()
fileSetAttributeInt32 file
file string
attribute Int32
value [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attribute ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ CString
attributePtr ->
            (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                                (\(File ForeignPtr File
arg1) CString
arg2 CInt
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) Ptr (Ptr ())
arg6 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CInt
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO CInt
g_file_set_attribute_int32 Ptr File
argPtr1 CString
arg2 CInt
arg3 CInt
arg4 Ptr Cancellable
argPtr5 Ptr (Ptr ())
arg6)
{-# LINE 1565 "./System/GIO/File/File.chs" #-}
                                   (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                                   CString
attributePtr
                                   (Int32 -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
value)
                                   ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                                   (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                                   Ptr (Ptr ())
gErrorPtr
                                () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Sets attribute of type 'FileAttributeTypeUint64' to value. If attribute is of a different type,
-- this operation will fail.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileSetAttributeWord64 :: (FileClass file, GlibString string) => file
 -> string -- ^ @attribute@ a string containing the attribute's name.
 -> Word64 -- ^ @value@ a Word64 containing the attribute's new value.
 -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileSetAttributeWord64 :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> Word64
-> [FileQueryInfoFlags]
-> Maybe Cancellable
-> IO ()
fileSetAttributeWord64 file
file string
attribute Word64
value [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attribute ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ CString
attributePtr ->
            (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                               (\(File ForeignPtr File
arg1) CString
arg2 CULong
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) Ptr (Ptr ())
arg6 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CULong
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO CInt
g_file_set_attribute_uint64 Ptr File
argPtr1 CString
arg2 CULong
arg3 CInt
arg4 Ptr Cancellable
argPtr5 Ptr (Ptr ())
arg6)
{-# LINE 1589 "./System/GIO/File/File.chs" #-}
                                   (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                                   CString
attributePtr
                                   (Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
value)
                                   ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                                   (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                                   Ptr (Ptr ())
gErrorPtr
                               () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Sets attribute of type 'FileAttributeTypeInt64' to value. If attribute is of a different type,
-- this operation will fail.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileSetAttributeInt64 :: (FileClass file, GlibString string) => file
 -> string -- ^ @attribute@ a string containing the attribute's name.
 -> Int64 -- ^ @value@ a Int64 containing the attribute's new value.
 -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileSetAttributeInt64 :: forall file string.
(FileClass file, GlibString string) =>
file
-> string
-> Int64
-> [FileQueryInfoFlags]
-> Maybe Cancellable
-> IO ()
fileSetAttributeInt64 file
file string
attribute Int64
value [FileQueryInfoFlags]
flags Maybe Cancellable
cancellable =
    string -> (CString -> IO ()) -> IO ()
forall a. string -> (CString -> IO a) -> IO a
forall s a. GlibString s => s -> (CString -> IO a) -> IO a
withUTFString string
attribute ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ CString
attributePtr ->
            (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                               (\(File ForeignPtr File
arg1) CString
arg2 CLong
arg3 CInt
arg4 (Cancellable ForeignPtr Cancellable
arg5) Ptr (Ptr ())
arg6 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg5 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr5 ->Ptr File
-> CString
-> CLong
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr ())
-> IO CInt
g_file_set_attribute_int64 Ptr File
argPtr1 CString
arg2 CLong
arg3 CInt
arg4 Ptr Cancellable
argPtr5 Ptr (Ptr ())
arg6)
{-# LINE 1613 "./System/GIO/File/File.chs" #-}
                                   (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                                   CString
attributePtr
                                   (Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
value)
                                   ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileQueryInfoFlags] -> Int) -> [FileQueryInfoFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileQueryInfoFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileQueryInfoFlags]
flags)
                                   (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                                   Ptr (Ptr ())
gErrorPtr
                               () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Copies the file attributes from source to destination.
--
-- Normally only a subset of the file attributes are copied, those that are copies in a normal file
-- copy operation (which for instance does not include e.g. owner). However if 'FileCopyAllMetadata'
-- is specified in flags, then all the metadata that is possible to copy is copied. This is useful when
-- implementing move by copy + delete source.
fileCopyAttributes :: (FileClass source, FileClass destination)
 => source -- ^ @source@ a 'File' with attributes.
 -> destination -- ^ @destination@ a 'File' to copy attributes to.
 -> [FileCopyFlags] -- ^ @flags@ a set of 'FileCopyFlags'.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileCopyAttributes :: forall source destination.
(FileClass source, FileClass destination) =>
source
-> destination -> [FileCopyFlags] -> Maybe Cancellable -> IO ()
fileCopyAttributes source
source destination
destination [FileCopyFlags]
flags Maybe Cancellable
cancellable =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(File ForeignPtr File
arg1) (File ForeignPtr File
arg2) CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) Ptr (Ptr ())
arg5 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg2 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr2 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> Ptr File -> CInt -> Ptr Cancellable -> Ptr (Ptr ()) -> IO CInt
g_file_copy_attributes Ptr File
argPtr1 Ptr File
argPtr2 CInt
arg3 Ptr Cancellable
argPtr4 Ptr (Ptr ())
arg5)
{-# LINE 1636 "./System/GIO/File/File.chs" #-}
                           (source -> File
forall o. FileClass o => o -> File
toFile source
source)
                           (destination -> File
forall o. FileClass o => o -> File
toFile destination
destination)
                           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileCopyFlags] -> Int) -> [FileCopyFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileCopyFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileCopyFlags]
flags)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                           Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Obtains a directory monitor for the given file. This may fail if directory monitoring is not
-- supported.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileMonitorDirectory :: FileClass file
                     => file
                     -> [FileMonitorFlags]
                     -> Maybe Cancellable
                     -> IO FileMonitor
fileMonitorDirectory :: forall file.
FileClass file =>
file -> [FileMonitorFlags] -> Maybe Cancellable -> IO FileMonitor
fileMonitorDirectory file
file [FileMonitorFlags]
flags Maybe Cancellable
cancellable =
    (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr FileMonitor)
-> IO (Ptr FileMonitor) -> IO FileMonitor
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr FileMonitor)
forall {a}. (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr a)
mkFileMonitor (IO (Ptr FileMonitor) -> IO FileMonitor)
-> IO (Ptr FileMonitor) -> IO FileMonitor
forall a b. (a -> b) -> a -> b
$
        (Ptr (Ptr ()) -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) Ptr (Ptr ())
arg4 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor))
-> (Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileMonitor))
-> IO (Ptr FileMonitor)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor))
-> (Ptr Cancellable -> IO (Ptr FileMonitor))
-> IO (Ptr FileMonitor)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CInt -> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr FileMonitor)
g_file_monitor_directory Ptr File
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3 Ptr (Ptr ())
arg4)
{-# LINE 1657 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileMonitorFlags] -> Int) -> [FileMonitorFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileMonitorFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileMonitorFlags]
flags)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        )

-- | Obtains a file monitor for the given file. If no file notification mechanism exists, then regular
-- polling of the file is used.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileMonitorFile :: FileClass file
                     => file
                     -> [FileMonitorFlags]
                     -> Maybe Cancellable
                     -> IO FileMonitor
fileMonitorFile :: forall file.
FileClass file =>
file -> [FileMonitorFlags] -> Maybe Cancellable -> IO FileMonitor
fileMonitorFile file
file [FileMonitorFlags]
flags Maybe Cancellable
cancellable =
    (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr FileMonitor)
-> IO (Ptr FileMonitor) -> IO FileMonitor
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr FileMonitor)
forall {a}. (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr a)
mkFileMonitor (IO (Ptr FileMonitor) -> IO FileMonitor)
-> IO (Ptr FileMonitor) -> IO FileMonitor
forall a b. (a -> b) -> a -> b
$
        (Ptr (Ptr ()) -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) Ptr (Ptr ())
arg4 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor))
-> (Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileMonitor))
-> IO (Ptr FileMonitor)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor))
-> (Ptr Cancellable -> IO (Ptr FileMonitor))
-> IO (Ptr FileMonitor)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CInt -> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr FileMonitor)
g_file_monitor_file Ptr File
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3 Ptr (Ptr ())
arg4)
{-# LINE 1676 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileMonitorFlags] -> Int) -> [FileMonitorFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileMonitorFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileMonitorFlags]
flags)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        )


-- | Obtains a file or directory monitor for the given file, depending on the type of the file.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileMonitor :: FileClass file
                     => file
                     -> [FileMonitorFlags]
                     -> Maybe Cancellable
                     -> IO FileMonitor
fileMonitor :: forall file.
FileClass file =>
file -> [FileMonitorFlags] -> Maybe Cancellable -> IO FileMonitor
fileMonitor file
file [FileMonitorFlags]
flags Maybe Cancellable
cancellable =
    (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr FileMonitor)
-> IO (Ptr FileMonitor) -> IO FileMonitor
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr FileMonitor)
forall {a}. (ForeignPtr FileMonitor -> FileMonitor, FinalizerPtr a)
mkFileMonitor (IO (Ptr FileMonitor) -> IO FileMonitor)
-> IO (Ptr FileMonitor) -> IO FileMonitor
forall a b. (a -> b) -> a -> b
$
        (Ptr (Ptr ()) -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) Ptr (Ptr ())
arg4 -> ForeignPtr File
-> (Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor))
-> (Ptr File -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileMonitor))
-> IO (Ptr FileMonitor)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO (Ptr FileMonitor)) -> IO (Ptr FileMonitor))
-> (Ptr Cancellable -> IO (Ptr FileMonitor))
-> IO (Ptr FileMonitor)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr File
-> CInt -> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr FileMonitor)
g_file_monitor Ptr File
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3 Ptr (Ptr ())
arg4)
{-# LINE 1695 "./System/GIO/File/File.chs" #-}
                           (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                           ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([FileMonitorFlags] -> Int) -> [FileMonitorFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [FileMonitorFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [FileMonitorFlags]
flags)
                           (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                        )


-- | Mounts a file of type 'FileTypeMountable'. Using @mountOperation@, you can request callbacks when,
-- for instance, passwords are needed during authentication.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileMountMountableFinish' to get the result of the operation.
fileMountMountable :: FileClass file => file
 -> [MountMountFlags] -- ^ @flags@ flags affecting the operation
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
fileMountMountable :: forall file.
FileClass file =>
file
-> [MountMountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileMountMountable file
file [MountMountFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(File ForeignPtr File
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_mount_mountable Ptr File
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 1719 "./System/GIO/File/File.chs" #-}
        (file -> File
forall o. FileClass o => o -> File
toFile file
file)
        ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([MountMountFlags] -> Int) -> [MountMountFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [MountMountFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [MountMountFlags]
flags)
        (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
        (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
        GAsyncReadyCallback
cCallback
        (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes a mount operation. See 'fileMountMountable' for details.
--
-- Finish an asynchronous mount operation that was started with 'fileMountMountable'.
fileMountMountableFinish :: FileClass file => file
 -> AsyncResult -- ^ @result@ a 'AsyncResult'
 -> IO File
fileMountMountableFinish :: forall file. FileClass file => file -> AsyncResult -> IO File
fileMountMountableFinish file
file AsyncResult
result =
    (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO (Ptr File)) -> IO (Ptr File)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr File -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr AsyncResult -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr File)
g_file_mount_mountable_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
result)


-- | Unmounts a file of type 'FileTypeMountable'.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileUnmountMountableFinish' to get the result of the operation.
fileUnmountMountableWithOperation :: FileClass file => file
 -> [MountUnmountFlags] -- ^ @flags@ flags affecting the operation
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
fileUnmountMountableWithOperation :: forall file.
FileClass file =>
file
-> [MountUnmountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileUnmountMountableWithOperation file
file [MountUnmountFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(File ForeignPtr File
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_unmount_mountable_with_operation Ptr File
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 1754 "./System/GIO/File/File.chs" #-}
          (file -> File
forall o. FileClass o => o -> File
toFile file
file)
          ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([MountUnmountFlags] -> Int) -> [MountUnmountFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [MountUnmountFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [MountUnmountFlags]
flags)
          (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
          (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          GAsyncReadyCallback
cCallback
          (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an unmount operation, see 'fileUnmountMountableWithOperation' for details.
--
-- Finish an asynchronous unmount operation that was started with
-- 'fileUnmountMountableWithOperation'.
--
-- Throws a 'GError' if an error occurs.
fileUnmountMountableWithOperationFinish :: FileClass file => file
 -> AsyncResult -- ^ @result@ a 'AsyncResult'
 -> IO ()
fileUnmountMountableWithOperationFinish :: forall file. FileClass file => file -> AsyncResult -> IO ()
fileUnmountMountableWithOperationFinish file
file AsyncResult
result =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_file_unmount_mountable_with_operation_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1773 "./System/GIO/File/File.chs" #-}
                          (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                          AsyncResult
result
                          Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Starts an asynchronous eject on a mountable. When this operation has completed, callback will be
-- called with @userUser@ data, and the operation can be finalized with
-- 'fileEjectMountableWithOperationFinish'.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileEjectMountableWithOperation :: FileClass file => file
 -> [MountUnmountFlags] -- ^ @flags@ flags affecting the operation
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
fileEjectMountableWithOperation :: forall file.
FileClass file =>
file
-> [MountUnmountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileEjectMountableWithOperation file
file [MountUnmountFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(File ForeignPtr File
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_eject_mountable_with_operation Ptr File
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 1794 "./System/GIO/File/File.chs" #-}
          (file -> File
forall o. FileClass o => o -> File
toFile file
file)
          ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([MountUnmountFlags] -> Int) -> [MountUnmountFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [MountUnmountFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [MountUnmountFlags]
flags)
          (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
          (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          GAsyncReadyCallback
cCallback
          (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an asynchronous eject operation started by 'fileEjectMountableWithOperation'.
--
-- Throws a 'GError' if an error occurs.
fileEjectMountableWithOperationFinish :: FileClass file => file
 -> AsyncResult -- ^ @result@ a 'AsyncResult'
 -> IO ()
fileEjectMountableWithOperationFinish :: forall file. FileClass file => file -> AsyncResult -> IO ()
fileEjectMountableWithOperationFinish file
file AsyncResult
result =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                        (\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_file_eject_mountable_with_operation_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1810 "./System/GIO/File/File.chs" #-}
                              (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                              AsyncResult
result
                              Ptr (Ptr ())
gErrorPtr
                        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Starts a file of type 'FileTypeMountable'. Using @startOperation@, you can request callbacks when,
-- for instance, passwords are needed during authentication.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileMountMountableFinish' to get the result of the operation.
fileStartMountable :: FileClass file
 => file
 -> [DriveStartFlags] -- ^ @flags@ flags affecting the start operation.
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
fileStartMountable :: forall file.
FileClass file =>
file
-> [DriveStartFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileStartMountable file
file [DriveStartFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(File ForeignPtr File
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_start_mountable Ptr File
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 1834 "./System/GIO/File/File.chs" #-}
        (file -> File
forall o. FileClass o => o -> File
toFile file
file)
        ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([DriveStartFlags] -> Int) -> [DriveStartFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [DriveStartFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [DriveStartFlags]
flags)
        (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
        (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
        GAsyncReadyCallback
cCallback
        (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes a start operation. See 'fileStartMountable' for details.
--
-- Finish an asynchronous start operation that was started with 'fileStartMountable'.
--
-- Throws a 'GError' if an error occurs.
fileStartMountableFinish :: FileClass file
 => file
 -> AsyncResult -- ^ @result@ a 'AsyncResult'.
 -> IO ()
fileStartMountableFinish :: forall file. FileClass file => file -> AsyncResult -> IO ()
fileStartMountableFinish file
file AsyncResult
result =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_file_start_mountable_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1853 "./System/GIO/File/File.chs" #-}
                          (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                          AsyncResult
result
                          Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Stops a file of type 'FileTypeMountable'.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileStopMountableFinish' to get the result of the operation.
fileStopMountable :: FileClass file
 => file
 -> [MountUnmountFlags] -- ^ @flags@ flags affecting the stop operation.
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
fileStopMountable :: forall file.
FileClass file =>
file
-> [MountUnmountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileStopMountable file
file [MountUnmountFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(File ForeignPtr File
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_stop_mountable Ptr File
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 1876 "./System/GIO/File/File.chs" #-}
        (file -> File
forall o. FileClass o => o -> File
toFile file
file)
        ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([MountUnmountFlags] -> Int) -> [MountUnmountFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [MountUnmountFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [MountUnmountFlags]
flags)
        (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
        (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
        GAsyncReadyCallback
cCallback
        (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes a stop operation. See 'fileStopMountable' for details.
--
-- Finish an asynchronous stop operation that was stopped with 'fileStopMountable'.
--
-- Throws a 'GError' if an error occurs.
fileStopMountableFinish :: FileClass file
 => file
 -> AsyncResult -- ^ @result@ a 'AsyncResult'.
 -> IO ()
fileStopMountableFinish :: forall file. FileClass file => file -> AsyncResult -> IO ()
fileStopMountableFinish file
file AsyncResult
result =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_file_stop_mountable_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 1895 "./System/GIO/File/File.chs" #-}
                          (file -> File
forall o. FileClass o => o -> File
toFile file
file)
                          AsyncResult
result
                          Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Polls a file of type 'FileTypeMountable'.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
--
-- When the operation is finished, callback will be called. You can then call
-- 'fileMountMountableFinish' to get the result of the operation.
filePollMountable :: FileClass file => file
 -> Maybe Cancellable
 -> AsyncReadyCallback
 -> IO ()
filePollMountable :: forall file.
FileClass file =>
file -> Maybe Cancellable -> AsyncReadyCallback -> IO ()
filePollMountable file
file Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(File ForeignPtr File
arg1) (Cancellable ForeignPtr Cancellable
arg2) GAsyncReadyCallback
arg3 Ptr ()
arg4 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr File
-> Ptr Cancellable -> GAsyncReadyCallback -> Ptr () -> IO ()
g_file_poll_mountable Ptr File
argPtr1 Ptr Cancellable
argPtr2 GAsyncReadyCallback
arg3 Ptr ()
arg4)
{-# LINE 1915 "./System/GIO/File/File.chs" #-}
          (file -> File
forall o. FileClass o => o -> File
toFile file
file)
          (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          GAsyncReadyCallback
cCallback
          (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes a poll operation. See 'filePollMountable' for details.
--
-- Finish an asynchronous poll operation that was polled with 'filePollMountable'.
filePollMountableFinish :: FileClass file
 => file
 -> AsyncResult -- ^ @result@ a 'AsyncResult'.
 -> IO Bool -- ^ returns 'True' if the file was successfully ejected. 'False' otherwise.
filePollMountableFinish :: forall file. FileClass file => file -> AsyncResult -> IO Bool
filePollMountableFinish file
file AsyncResult
result =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_file_poll_mountable_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
result)


-- | Starts a @mountOperation@, mounting the volume that contains the file location.
--
-- When this operation has completed, callback will be called with @userUser@ data, and the operation
-- can be finalized with 'fileMountEnclosingVolumeFinish'.
--
-- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object
-- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be
-- returned.
fileMountEnclosingVolume :: FileClass file => file
 -> [MountMountFlags] -- ^ @flags@ flags affecting the operation
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
fileMountEnclosingVolume :: forall file.
FileClass file =>
file
-> [MountMountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileMountEnclosingVolume file
file [MountMountFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(File ForeignPtr File
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr File -> (Ptr File -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO ()) -> IO ()) -> (Ptr File -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr File
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_mount_enclosing_volume Ptr File
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 1949 "./System/GIO/File/File.chs" #-}
        (file -> File
forall o. FileClass o => o -> File
toFile file
file)
        ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([MountMountFlags] -> Int) -> [MountMountFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [MountMountFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [MountMountFlags]
flags)
        (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
        (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
        GAsyncReadyCallback
cCallback
        (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes a mount operation started by 'fileMountEnclosingVolume'.
fileMountEnclosingVolumeFinish :: FileClass file
 => file
 -> AsyncResult -- ^ @result@ a 'AsyncResult'.
 -> IO Bool -- ^ returns 'True' if the file was successfully ejected. 'False' otherwise.
fileMountEnclosingVolumeFinish :: forall file. FileClass file => file -> AsyncResult -> IO Bool
fileMountEnclosingVolumeFinish file
file AsyncResult
result =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
    (Ptr (Ptr ()) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(File ForeignPtr File
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr File -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_file_mount_enclosing_volume_finish Ptr File
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (file -> File
forall o. FileClass o => o -> File
toFile file
file) AsyncResult
result)


-- | Checks if file supports thread-default contexts. If this returns 'False', you cannot perform
-- asynchronous operations on file in a thread that has a thread-default context.
fileSupportsThreadContexts :: FileClass file => file
 -> IO Bool -- ^ returns Whether or not file supports thread-default contexts.
fileSupportsThreadContexts :: forall file. FileClass file => file -> IO Bool
fileSupportsThreadContexts file
file =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO CInt) -> IO CInt)
-> (Ptr File -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO CInt
g_file_supports_thread_contexts Ptr File
argPtr1) (file -> File
forall o. FileClass o => o -> File
toFile file
file)

foreign import ccall safe "g_file_new_for_path"
  g_file_new_for_path :: ((Ptr CChar) -> (IO (Ptr File)))

foreign import ccall safe "g_file_new_for_uri"
  g_file_new_for_uri :: ((Ptr CChar) -> (IO (Ptr File)))

foreign import ccall safe "g_file_new_for_commandline_arg"
  g_file_new_for_commandline_arg :: ((Ptr CChar) -> (IO (Ptr File)))

foreign import ccall safe "g_file_parse_name"
  g_file_parse_name :: ((Ptr CChar) -> (IO (Ptr File)))

foreign import ccall safe "g_file_equal"
  g_file_equal :: ((Ptr File) -> ((Ptr File) -> (IO CInt)))

foreign import ccall safe "g_file_get_basename"
  g_file_get_basename :: ((Ptr File) -> (IO (Ptr CChar)))

foreign import ccall unsafe "g_free"
  g_free :: ((Ptr ()) -> (IO ()))

foreign import ccall safe "g_file_get_path"
  g_file_get_path :: ((Ptr File) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_get_uri"
  g_file_get_uri :: ((Ptr File) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_get_parse_name"
  g_file_get_parse_name :: ((Ptr File) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_get_parent"
  g_file_get_parent :: ((Ptr File) -> (IO (Ptr File)))

foreign import ccall safe "g_file_has_parent"
  g_file_has_parent :: ((Ptr File) -> ((Ptr File) -> (IO CInt)))

foreign import ccall safe "g_file_get_child"
  g_file_get_child :: ((Ptr File) -> ((Ptr CChar) -> (IO (Ptr File))))

foreign import ccall safe "g_file_get_child_for_display_name"
  g_file_get_child_for_display_name :: ((Ptr File) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO (Ptr File)))))

foreign import ccall safe "g_file_has_prefix"
  g_file_has_prefix :: ((Ptr File) -> ((Ptr File) -> (IO CInt)))

foreign import ccall safe "g_file_get_relative_path"
  g_file_get_relative_path :: ((Ptr File) -> ((Ptr File) -> (IO (Ptr CChar))))

foreign import ccall safe "g_file_resolve_relative_path"
  g_file_resolve_relative_path :: ((Ptr File) -> ((Ptr CChar) -> (IO (Ptr File))))

foreign import ccall safe "g_file_is_native"
  g_file_is_native :: ((Ptr File) -> (IO CInt))

foreign import ccall safe "g_file_has_uri_scheme"
  g_file_has_uri_scheme :: ((Ptr File) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "g_file_get_uri_scheme"
  g_file_get_uri_scheme :: ((Ptr File) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_read"
  g_file_read :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileInputStream)))))

foreign import ccall safe "g_file_read_async"
  g_file_read_async :: ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ()))))))

foreign import ccall safe "g_file_read_finish"
  g_file_read_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr FileInputStream)))))

foreign import ccall safe "g_file_append_to"
  g_file_append_to :: ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileOutputStream))))))

foreign import ccall safe "g_file_create"
  g_file_create :: ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileOutputStream))))))

foreign import ccall safe "g_file_replace"
  g_file_replace :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileOutputStream))))))))

foreign import ccall safe "g_file_append_to_async"
  g_file_append_to_async :: ((Ptr File) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_append_to_finish"
  g_file_append_to_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr FileOutputStream)))))

foreign import ccall safe "g_file_create_async"
  g_file_create_async :: ((Ptr File) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_create_finish"
  g_file_create_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr FileOutputStream)))))

foreign import ccall safe "g_file_replace_async"
  g_file_replace_async :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))))

foreign import ccall safe "g_file_replace_finish"
  g_file_replace_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr FileOutputStream)))))

foreign import ccall safe "g_file_query_info"
  g_file_query_info :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileInfo)))))))

foreign import ccall safe "g_file_query_info_async"
  g_file_query_info_async :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ()))))))))

foreign import ccall safe "g_file_query_info_finish"
  g_file_query_info_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr FileInfo)))))

foreign import ccall safe "g_file_query_exists"
  g_file_query_exists :: ((Ptr File) -> ((Ptr Cancellable) -> (IO CInt)))

foreign import ccall safe "g_file_query_file_type"
  g_file_query_file_type :: ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> (IO CInt))))

foreign import ccall safe "g_file_query_filesystem_info"
  g_file_query_filesystem_info :: ((Ptr File) -> ((Ptr CChar) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileInfo))))))

foreign import ccall safe "g_file_query_filesystem_info_async"
  g_file_query_filesystem_info_async :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_query_filesystem_info_finish"
  g_file_query_filesystem_info_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr FileInfo)))))

foreign import ccall safe "g_file_query_default_handler"
  g_file_query_default_handler :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr AppInfo)))))

foreign import ccall safe "g_file_find_enclosing_mount"
  g_file_find_enclosing_mount :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr Mount)))))

foreign import ccall safe "g_file_find_enclosing_mount_async"
  g_file_find_enclosing_mount_async :: ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ()))))))

foreign import ccall safe "g_file_find_enclosing_mount_finish"
  g_file_find_enclosing_mount_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr Mount)))))

foreign import ccall safe "g_file_enumerate_children"
  g_file_enumerate_children :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileEnumerator)))))))

foreign import ccall safe "g_file_enumerate_children_async"
  g_file_enumerate_children_async :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ()))))))))

foreign import ccall safe "g_file_enumerate_children_finish"
  g_file_enumerate_children_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr FileEnumerator)))))

foreign import ccall safe "g_file_set_display_name"
  g_file_set_display_name :: ((Ptr File) -> ((Ptr CChar) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr File))))))

foreign import ccall safe "g_file_set_display_name_async"
  g_file_set_display_name_async :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_set_display_name_finish"
  g_file_set_display_name_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr File)))))

foreign import ccall safe "g_file_delete"
  g_file_delete :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_trash"
  g_file_trash :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_copy"
  g_file_copy :: ((Ptr File) -> ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((FunPtr (CLong -> (CLong -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> ((Ptr (Ptr ())) -> (IO CInt))))))))

foreign import ccall safe "g_file_copy_async"
  g_file_copy_async :: ((Ptr File) -> ((Ptr File) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((FunPtr (CLong -> (CLong -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ()))))))))))

foreign import ccall safe "g_file_copy_finish"
  g_file_copy_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_move"
  g_file_move :: ((Ptr File) -> ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((FunPtr (CLong -> (CLong -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> ((Ptr (Ptr ())) -> (IO CInt))))))))

foreign import ccall safe "g_file_make_directory"
  g_file_make_directory :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_make_directory_with_parents"
  g_file_make_directory_with_parents :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_make_symbolic_link"
  g_file_make_symbolic_link :: ((Ptr File) -> ((Ptr CChar) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt)))))

foreign import ccall safe "g_file_query_settable_attributes"
  g_file_query_settable_attributes :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileAttributeInfoList)))))

foreign import ccall safe "g_file_query_writable_namespaces"
  g_file_query_writable_namespaces :: ((Ptr File) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileAttributeInfoList)))))

foreign import ccall safe "g_file_set_attributes_from_info"
  g_file_set_attributes_from_info :: ((Ptr File) -> ((Ptr FileInfo) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt))))))

foreign import ccall safe "g_file_set_attributes_async"
  g_file_set_attributes_async :: ((Ptr File) -> ((Ptr FileInfo) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ()))))))))

foreign import ccall safe "g_file_set_attributes_finish"
  g_file_set_attributes_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr FileInfo) -> ((Ptr (Ptr ())) -> (IO CInt)))))

foreign import ccall safe "g_file_set_attribute_string"
  g_file_set_attribute_string :: ((Ptr File) -> ((Ptr CChar) -> ((Ptr CChar) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt)))))))

foreign import ccall safe "g_file_set_attribute_byte_string"
  g_file_set_attribute_byte_string :: ((Ptr File) -> ((Ptr CChar) -> ((Ptr CChar) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt)))))))

foreign import ccall safe "g_file_set_attribute_uint32"
  g_file_set_attribute_uint32 :: ((Ptr File) -> ((Ptr CChar) -> (CUInt -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt)))))))

foreign import ccall safe "g_file_set_attribute_int32"
  g_file_set_attribute_int32 :: ((Ptr File) -> ((Ptr CChar) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt)))))))

foreign import ccall safe "g_file_set_attribute_uint64"
  g_file_set_attribute_uint64 :: ((Ptr File) -> ((Ptr CChar) -> (CULong -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt)))))))

foreign import ccall safe "g_file_set_attribute_int64"
  g_file_set_attribute_int64 :: ((Ptr File) -> ((Ptr CChar) -> (CLong -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt)))))))

foreign import ccall safe "g_file_copy_attributes"
  g_file_copy_attributes :: ((Ptr File) -> ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt))))))

foreign import ccall safe "g_file_monitor_directory"
  g_file_monitor_directory :: ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileMonitor))))))

foreign import ccall safe "g_file_monitor_file"
  g_file_monitor_file :: ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileMonitor))))))

foreign import ccall safe "g_file_monitor"
  g_file_monitor :: ((Ptr File) -> (CInt -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileMonitor))))))

foreign import ccall safe "g_file_mount_mountable"
  g_file_mount_mountable :: ((Ptr File) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_mount_mountable_finish"
  g_file_mount_mountable_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr File)))))

foreign import ccall safe "g_file_unmount_mountable_with_operation"
  g_file_unmount_mountable_with_operation :: ((Ptr File) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_unmount_mountable_with_operation_finish"
  g_file_unmount_mountable_with_operation_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_eject_mountable_with_operation"
  g_file_eject_mountable_with_operation :: ((Ptr File) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_eject_mountable_with_operation_finish"
  g_file_eject_mountable_with_operation_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_start_mountable"
  g_file_start_mountable :: ((Ptr File) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_start_mountable_finish"
  g_file_start_mountable_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_stop_mountable"
  g_file_stop_mountable :: ((Ptr File) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_stop_mountable_finish"
  g_file_stop_mountable_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_poll_mountable"
  g_file_poll_mountable :: ((Ptr File) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))

foreign import ccall safe "g_file_poll_mountable_finish"
  g_file_poll_mountable_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_mount_enclosing_volume"
  g_file_mount_enclosing_volume :: ((Ptr File) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_mount_enclosing_volume_finish"
  g_file_mount_enclosing_volume_finish :: ((Ptr File) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_supports_thread_contexts"
  g_file_supports_thread_contexts :: ((Ptr File) -> (IO CInt))