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
260fs::path
261get_next_available_filepath (const fs::path &filepath);
262
270Utf8String
271get_legal_file_name (const Utf8String &file_name);
272
276Utf8String
277get_legal_path_name (const Utf8String &path);
278
279#ifdef _WIN32
283utils::Utf8String
284get_registry_string_val (const utils::Utf8String &key);
285#endif
286
287#if defined(__APPLE__) && ZRYTHM_IS_INSTALLER_VER
293[[gnu::nonnull]] int
294get_bundle_path (char * bundle_path);
295#endif
296
300bool
301path_exists (const fs::path &path);
302
303bool
304is_file_hidden (const fs::path &file);
305
311[[nodiscard]] bool
312reflink_file (const fs::path &dest, const fs::path &src);
313
321[[nodiscard]] QByteArray
322read_file_contents (const fs::path &path);
323
331void
332set_file_contents (const fs::path &path, const char * contents, size_t size);
333
341void
342set_file_contents (const fs::path &file_path, const utils::Utf8String &data);
343
352QStringList
353split_paths (const QString &paths);
354
355}; // namespace zrythm::utils::io
356
357#endif