Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
io.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
8#ifndef __UTILS_IO_H__
9#define __UTILS_IO_H__
10
11#include "zrythm-config.h"
12
13#include <stdbool.h>
14#include <stdio.h>
15
16#include <glib.h>
17
29NONNULL char *
30io_get_dir (const char * filename);
31
38WARN_UNUSED_RESULT NONNULL_ARGS (
39 1) bool io_mkdir (const char * dir, GError ** error);
40
44NONNULL FILE *
45io_create_file (const char * filename);
46
50void
51io_touch_file (const char * filename);
52
53NONNULL char *
54io_path_get_parent_dir (const char * path);
55
59NONNULL char *
60io_file_strip_ext (const char * filename);
61
65NONNULL const char *
66io_file_get_ext (const char * file);
67
68#define io_path_get_basename(filename) g_path_get_basename (filename)
69
75NONNULL char *
76io_path_get_basename_without_ext (const char * filename);
77
78NONNULL char *
79io_file_get_creation_datetime (const char * filename);
80
85NONNULL gint64
86io_file_get_last_modified_datetime (const char * filename);
87
88NONNULL char *
89io_file_get_last_modified_datetime_as_str (const char * filename);
90
94NONNULL int
95io_remove (const char * path);
96
104NONNULL int
105io_rmdir (const char * path, bool force);
106
107char **
108io_get_files_in_dir_as_basenames (
109 const char * dir,
110 bool allow_empty,
111 bool with_ext);
112
120#define io_get_files_in_dir(dir, allow_empty) \
121 io_get_files_in_dir_ending_in (dir, 0, NULL, allow_empty)
122
134char **
136 const char * _dir,
137 const int recursive,
138 const char * end_string,
139 bool allow_empty);
140
151WARN_UNUSED_RESULT bool
153 const char * destdir_str,
154 const char * srcdir_str,
155 bool follow_symlinks,
156 bool recursive,
157 GError ** error);
158
167NONNULL char *
168io_get_next_available_filepath (const char * filepath);
169
174NONNULL void
175io_open_directory (const char * path);
176
181NONNULL void
182io_escape_dir_name (char * dest, const char * dir);
183
184#define io_write_file g_file_set_contents
185
186#ifdef _WOE32
187char *
188io_get_registry_string_val (const char * path);
189#endif
190
191#if defined(__APPLE__) && defined(INSTALLER_VER)
197NONNULL int
198io_get_bundle_path (char * bundle_path);
199#endif
200
205NONNULL char *
206io_traverse_path (const char * abs_path);
207
212#endif
NONNULL char * io_path_get_basename_without_ext(const char *filename)
Strips path from given filename.
NONNULL char * io_traverse_path(const char *abs_path)
Returns the new path after traversing any symlinks (using readlink()).
NONNULL char * io_get_next_available_filepath(const char *filepath)
Returns a newly allocated path that is either a copy of the original path if the path does not exist,...
WARN_UNUSED_RESULT bool io_copy_dir(const char *destdir_str, const char *srcdir_str, bool follow_symlinks, bool recursive, GError **error)
Copies a directory.
NONNULL char * io_get_dir(const char *filename)
Gets directory part of filename.
NONNULL void io_open_directory(const char *path)
Opens the given directory using the default program.
NONNULL const char * io_file_get_ext(const char *file)
Returns file extension or NULL.
WARN_UNUSED_RESULT NONNULL_ARGS(1) bool io_mkdir(const char *dir
Makes directory if doesn't exist.
void io_touch_file(const char *filename)
Touches a file similar to UNIX touch.
char ** io_get_files_in_dir_ending_in(const char *_dir, const int recursive, const char *end_string, bool allow_empty)
Returns a list of the files in the given directory.
NONNULL gint64 io_file_get_last_modified_datetime(const char *filename)
Returns the number of seconds since the epoch, or -1 if failed.
NONNULL void io_escape_dir_name(char *dest, const char *dir)
Returns a clone of the given string after removing forbidden characters.
NONNULL int io_remove(const char *path)
Removes the given file.
NONNULL FILE * io_create_file(const char *filename)
Creates the file if doesn't exist.
NONNULL char * io_file_strip_ext(const char *filename)
Strips extensions from given filename.
NONNULL int io_rmdir(const char *path, bool force)
Removes a dir, optionally forcing deletion.