OGMRip Reference Manual: Filesystem

## Filesystem Filesystem — Functions for handling files, directories, links and fifos |

## Functions

void | ogmrip_fs_unref ()
const gchar * | ogmrip_fs_get_tmp_dir ()
void | ogmrip_fs_set_tmp_dir ()
gboolean | ogmrip_fs_mkdir ()
gboolean | ogmrip_fs_rmdir ()
gchar * | ogmrip_fs_mktemp ()
gchar * | ogmrip_fs_mkftemp ()
gchar * | ogmrip_fs_mkdtemp ()
gchar * | ogmrip_fs_lntemp ()
gint | ogmrip_fs_open_tmp ()
gchar * | ogmrip_fs_get_full_path ()
gint64 | ogmrip_fs_get_left_space ()
gchar * | ogmrip_fs_get_mount_point ()
const gchar * | ogmrip_fs_get_extension ()
gchar * | ogmrip_fs_set_extension ()
gboolean | ogmrip_fs_rename ()

## Object Hierarchy

## Includes

    #include <ogmrip-fs.h>

## Description

## Functions

### ogmrip_fs_unref ()

    void
    ogmrip_fs_unref (gchar *filename,
                     gboolean do_unlink);

If `do_unlink` is `TRUE`, recursively removes `filename` then frees the memory pointed to by `filename` .

#### Parameters

filename | A path to a filename |
do_unlink | `TRUE` to also remove the file |

### ogmrip_fs_get_tmp_dir ()

    const gchar *
    ogmrip_fs_get_tmp_dir (void);

Returns OGMRip's temporary directory.

#### Returns

The temporaty directory

### ogmrip_fs_set_tmp_dir ()

    void
    ogmrip_fs_set_tmp_dir (const gchar *dir);

Sets OGMRip's temporary directory. If `dir` is NULL, OGMRip's temporary directory will be the system's temporary directory.

#### Parameters

dir | The new temporary directory |

### ogmrip_fs_mkdir ()

    gboolean
    ogmrip_fs_mkdir (const gchar *path,
                     mode_t mode,
                     GError **error);

Create the all the directories in `path` , if they do not already exist.

#### Parameters

path | A path of directories |
mode | The file mode |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

`TRUE` on success, `FALSE` if an error was set

### ogmrip_fs_rmdir ()

    gboolean
    ogmrip_fs_rmdir (const gchar *path,
                     gboolean recursive,
                     GError **error);

If `recusive` is `FALSE`, removes the directory of `path` if it is empty. If `recusive` is `TRUE`, also removes its content recursively.

#### Parameters

path | A path to a directory |
recursive | `TRUE` to remove the directory and its content recursively |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

`TRUE` on success, `FALSE` if an error was set

### ogmrip_fs_mktemp ()

    gchar *
    ogmrip_fs_mktemp (const gchar *tmpl,
                      GError **error);

Creates a file in OGMRip's temporary directory (as returned by `ogmrip_fs_get_tmp_dir()`).

#### Parameters

tmpl | Template for file name, as in `g_mkstemp()`, basename only |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

The actual name used, or NULL

### ogmrip_fs_mkftemp ()

    gchar *
    ogmrip_fs_mkftemp (const gchar *tmpl,
                       GError **error);

Creates a fifo in OGMRip's temporary directory (as returned by `ogmrip_fs_get_tmp_dir()`).

#### Parameters

tmpl | Template for fifo name, basename only |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

The actual name used, or NULL

### ogmrip_fs_mkdtemp ()

    gchar *
    ogmrip_fs_mkdtemp (const gchar *tmpl,
                       GError **error);

Creates a directory in OGMRip's temporary directory (as returned by `ogmrip_fs_get_tmp_dir()`).

#### Parameters

tmpl | Template for directory name, basename only |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

The actual name used, or NULL

### ogmrip_fs_lntemp ()

    gchar *
    ogmrip_fs_lntemp (const gchar *oldpath,
                      const gchar *newtmpl,
                      gboolean symln,
                      GError **error);

Creates a link in OGMRip's temporary directory (as * returned by `ogmrip_fs_get_tmp_dir()`) to æn existing file.

#### Parameters

oldpath | A path to an existing file |
newtmpl | Template for link name, basename only |
symln | `TRUE` to create a symbolic link |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

The actual name used, or NULL

### ogmrip_fs_open_tmp ()

    gint
    ogmrip_fs_open_tmp (const gchar *tmpl,
                        gchar **name_used,
                        GError **error);

Opens a file for writing in OGMRip's temporary directory (as returned by `g_get_tmp_dir()`).

#### Parameters

tmpl | Template for file name, as in `g_mkstemp()`, basename only |
name_used | Location to store actual name used |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

A file handle (as from `open()`) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with `close()`. In case of errors, -1 is returned and `error` will be set.

### ogmrip_fs_get_full_path ()

    gchar *
    ogmrip_fs_get_full_path (const gchar *filename);

Return the full absolute path of `filename` .

#### Parameters

filename | The path to an existing filename |

#### Returns

the full path, or NULL

### ogmrip_fs_get_left_space ()

    gint64
    ogmrip_fs_get_left_space (const gchar *filename,
                              GError **error);

Returns the space left in bytes on the device containing `filename` .

#### Parameters

filename | A path to a filename |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

The space left in bytes, or -1

### ogmrip_fs_get_mount_point ()

    gchar *
    ogmrip_fs_get_mount_point (const gchar *filename,
                               GError **error);

Returns the mount point of the device containing `filename` .

#### Parameters

filename | A path to a filename |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

The moint point, or NULL

### ogmrip_fs_get_extension ()

    const gchar *
    ogmrip_fs_get_extension (const gchar *filename);

Returns the extension of `filename` .

#### Parameters

filename | The path to an existing filename |

#### Returns

The extension, or NULL

### ogmrip_fs_set_extension ()

    gchar *
    ogmrip_fs_set_extension (const gchar *filename,
                             const gchar *extension);

If `filename` already has an extension, replaces it with `extension` . If not, appends `extension` to `filename` .

#### Parameters

filename | The path to an existing filename |
extension | The new extension |

#### Returns

The new name of the file, or NULL

### ogmrip_fs_rename ()

    gboolean
    ogmrip_fs_rename (const gchar *old_name,
                      const gchar *new_name,
                      GError **error);

If `recusive` is `FALSE`, removes the directory of `path` if it is empty. If `recusive` is `TRUE`, also removes its content recursively.

#### Parameters

old_name | The path to an existing filename |
new_name | The new name of the file |
error | A location to return an error of type G_FILE_ERROR |

#### Returns

`TRUE` on success, `FALSE` if an error was set

## Types and Values