### Function

# GLib access

since: 2.8

#### Declaration

    int
    g_access (
      const gchar* filename,
      int mode
    )

#### Description

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

On Windows, the file protection mechanism is not at all POSIX-like, and the underlying function in the C library only checks the FAT-style READONLY attribute, and does not look at the ACL of a file at all. This function is this in practise almost useless on Windows. Software that needs to handle file permissions on Windows more exactly should use the Win32 API.

See your C library manual for more details about access().

Available since: 2.8

#### Parameters

`filename`

  Type: `const gchar*`

  A pathname in the GLib file name encoding (UTF-8 on Windows)

  The data is owned by the caller of the function.
  The value is a file system path, using the OS encoding.

`mode`

  Type: `int`

  As in `access()`

#### Return value

Type: `int`

Zero if the pathname refers to an existing file system object that has all the tested permissions, or -1 otherwise or on error.