Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
io_utils.h
1// SPDX-FileCopyrightText: © 2018-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __UTILS_IO_H__
5#define __UTILS_IO_H__
6
7#include "zrythm-config.h"
8
9#include <optional>
10
11#include "utils/utf8_string.h"
12
13#include <QTemporaryDir>
14#include <QTemporaryFile>
15
16namespace zrythm::utils::io
17{
18
22utils::Utf8String
23get_path_separator_string ();
24
28fs::path
29get_home_path ();
30
31fs::path
32get_temp_path ();
33
46fs::path
47get_dir (const fs::path &filename);
48
54void
55mkdir (const fs::path &dir);
56
62bool
63touch_file (const fs::path &file_path);
64
65fs::path
66uri_to_file (const utils::Utf8String &uri);
67
71fs::path
72file_strip_ext (const fs::path &filename);
73
77fs::path
78file_get_ext (const fs::path &file);
79
90fs::path
91path_get_basename (const fs::path &filename);
92
104fs::path
105path_get_basename_without_ext (const fs::path &filename);
106
111qint64
112file_get_last_modified_datetime (const fs::path &filename);
113
114Utf8String
115file_get_last_modified_datetime_as_str (const fs::path &filename);
116
127bool
128remove (const fs::path &path);
129
148std::unique_ptr<QTemporaryDir>
149make_tmp_dir (
150 std::optional<QString> template_path = std::nullopt,
151 bool in_temp_dir = true);
152
156inline std::unique_ptr<QTemporaryDir>
157make_tmp_dir_at_path (const fs::path &absolute_template_path)
158{
159 return make_tmp_dir (
160 Utf8String::from_path (absolute_template_path).to_qstring (), false);
161}
162
172std::unique_ptr<QTemporaryFile>
173make_tmp_file (
174 std::optional<utils::Utf8String> template_path = std::nullopt,
175 bool in_temp_dir = true);
176
185bool
186rmdir (const fs::path &path, bool force);
187
194std::vector<fs::path>
195get_files_in_dir_as_basenames (const fs::path &_dir);
196
204std::vector<fs::path>
205get_files_in_dir_ending_in (
206 const fs::path &_dir,
207 bool recursive,
208 const std::optional<utils::Utf8String> &end_string);
209
217std::vector<fs::path>
218get_files_in_dir (const fs::path &_dir);
219
231void
232copy_dir (
233 const fs::path &destdir,
234 const fs::path &srcdir,
235 bool follow_symlinks,
236 bool recursive);
237
249void
250copy_file (const fs::path &destfile, const fs::path &srcfile);
251
259void
260move_file (const fs::path &destfile, const fs::path &srcfile);
261
270fs::path
271get_next_available_filepath (const fs::path &filepath);
272
280Utf8String
281get_legal_file_name (const Utf8String &file_name);
282
286Utf8String
287get_legal_path_name (const Utf8String &path);
288
289#ifdef _WIN32
293utils::Utf8String
294get_registry_string_val (const utils::Utf8String &key);
295#endif
296
297#if defined(__APPLE__) && ZRYTHM_IS_INSTALLER_VER
303[[gnu::nonnull]] int
304get_bundle_path (char * bundle_path);
305#endif
306
310bool
311path_exists (const fs::path &path);
312
313bool
314is_file_hidden (const fs::path &file);
315
321[[nodiscard]] bool
322reflink_file (const fs::path &dest, const fs::path &src);
323
331[[nodiscard]] QByteArray
332read_file_contents (const fs::path &path);
333
341void
342set_file_contents (const fs::path &path, const char * contents, size_t size);
343
351void
352set_file_contents (const fs::path &file_path, const utils::Utf8String &data);
353
362QStringList
363split_paths (const QString &paths);
364
365}; // namespace zrythm::utils::io
366
367#endif