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 <cstdio>
14
15#include <glib.h>
16
28NONNULL char *
29io_get_dir (const char * filename);
30
37WARN_UNUSED_RESULT NONNULL_ARGS (
38 1) bool io_mkdir (const char * dir, GError ** error);
39
43NONNULL FILE *
44io_create_file (const char * filename);
45
49void
50io_touch_file (const char * filename);
51
52NONNULL char *
53io_path_get_parent_dir (const char * path);
54
58NONNULL char *
59io_file_strip_ext (const char * filename);
60
64NONNULL const char *
65io_file_get_ext (const char * file);
66
67#define io_path_get_basename(filename) g_path_get_basename (filename)
68
74NONNULL char *
75io_path_get_basename_without_ext (const char * filename);
76
77NONNULL char *
78io_file_get_creation_datetime (const char * filename);
79
84NONNULL gint64
85io_file_get_last_modified_datetime (const char * filename);
86
87NONNULL char *
88io_file_get_last_modified_datetime_as_str (const char * filename);
89
93NONNULL int
94io_remove (const char * path);
95
103NONNULL int
104io_rmdir (const char * path, bool force);
105
106char **
107io_get_files_in_dir_as_basenames (
108 const char * dir,
109 bool allow_empty,
110 bool with_ext);
111
119#define io_get_files_in_dir(dir, allow_empty) \
120 io_get_files_in_dir_ending_in (dir, 0, NULL, allow_empty)
121
133char **
135 const char * _dir,
136 const int recursive,
137 const char * end_string,
138 bool allow_empty);
139
150WARN_UNUSED_RESULT bool
152 const char * destdir_str,
153 const char * srcdir_str,
154 bool follow_symlinks,
155 bool recursive,
156 GError ** error);
157
166NONNULL char *
167io_get_next_available_filepath (const char * filepath);
168
173NONNULL void
174io_open_directory (const char * path);
175
180NONNULL void
181io_escape_dir_name (char * dest, const char * dir);
182
183#define io_write_file g_file_set_contents
184
185#ifdef _WIN32
186char *
187io_get_registry_string_val (const char * path);
188#endif
189
190#if defined(__APPLE__) && defined(INSTALLER_VER)
196NONNULL int
197io_get_bundle_path (char * bundle_path);
198#endif
199
204NONNULL char *
205io_traverse_path (const char * abs_path);
206
211#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.