Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 128 lines (101 sloc) 4.693 kb
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
1 // -*- c++ -*-
4d4d90b @hzeller o More legalese
authored
2 // Folve - A fuse filesystem that convolves audio files on-the-fly.
3 //
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
4 // Copyright (C) 2012 Henner Zeller <h.zeller@acm.org>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
19 #ifndef FOLVE_FILESYSTEM_H
20 #define FOLVE_FILESYSTEM_H
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
21
22 #include <unistd.h>
23
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
24 #include <string>
25 #include <vector>
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
26 #include <set>
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
27
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
28 #include "file-handler-cache.h"
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
29 #include "file-handler.h"
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
30
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
31 #ifndef FOLVE_VERSION
32 #define FOLVE_VERSION "[unknown version - compile from git]"
33 #endif
34
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
35 class FolveFilesystem {
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
36 public:
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
37 // Create a new filesystem. At least SetBasedir() needs to be called
38 // for this to be properly initialized.
39 FolveFilesystem();
40
41 // Underlying directory - the directory we read files from.
42 void set_underlying_dir(const std::string &dir) { underlying_dir_ = dir; }
43 const std::string &underlying_dir() const { return underlying_dir_; }
44
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored
45 // Set the base configuration directory.
46 void SetBaseConfigDir(const std::string &config_dir) {
47 base_config_dir_ = config_dir;
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
48 }
49
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored
50 // Return a set of available named configurations. Essentially the names
51 // of subdirectories in the configuration dir.
52 const std::set<std::string> GetAvailableConfigDirs() const;
53
54 // Switch the current config to subdir. Returns 'true', if this was a valid
55 // choice and we actually did a switch to a new directory.
56 bool SwitchCurrentConfigDir(const std::string &subdir);
57 const std::string &current_config_subdir() const {
58 return current_config_subdir_;
59 }
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
60
61 // Check if properly initialized. Return 'false' if not and print a message
62 // to stderr.
63 bool CheckInitialized();
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
64
a90d922 @hzeller o Separate sanitizing of config subdirectories.
authored
65 // After startup: choose the initial configuation.
66 void SetupInitialConfig();
67
0aee3bb @hzeller o Show base dir that is mounted.
authored
68 // Create a new filter given the filesystem path and the underlying
69 // path.
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
70 // Returns NULL, if it cannot be created.
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
71 FileHandler *GetOrCreateHandler(const char *fs_path);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
72
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
73 // Inform filesystem that this file handler is not needed anymore
74 // (FS still might consider keeping it around for a while).
75 void Close(const char *fs_path, const FileHandler *handler);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
76
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
77 // Return dynamic size of file.
78 int StatByFilename(const char *fs_path, struct stat *st);
79
ac40d85 @hzeller o Make sure we match the alphabetically next file with
authored
80 // List files in given filesystem directory that match the suffix.
81 // Returns a set of filesystem paths of existing files.
82 // (We don't want globbing as filenames might contain weird characters).
83 bool ListDirectory(const std::string &fs_dir, const std::string &suffix,
84 std::set<std::string> *files);
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
85
b5c1e96 @hzeller o more useful output on status server.
authored
86 FileHandlerCache *handler_cache() { return &open_file_cache_; }
0aee3bb @hzeller o Show base dir that is mounted.
authored
87
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
88 void set_debug_ui_enabled(bool b) { debug_ui_enabled_ = b; }
89 bool is_debug_ui_enabled() const { return debug_ui_enabled_; }
90
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
91 void set_gapless_processing(bool b) { gapless_processing_ = b; }
92 bool gapless_processing() const { return gapless_processing_; }
93
0aee3bb @hzeller o Show base dir that is mounted.
authored
94 // Some stats.
b5c1e96 @hzeller o more useful output on status server.
authored
95 int total_file_openings() { return total_file_openings_; }
96 int total_file_reopen() { return total_file_reopen_; }
97
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
98 private:
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
99 // Get cache key, depending on the given configuration.
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored
100 std::string CacheKey(const std::string &config_path, const char *fs_path);
8268c37 @hzeller o Bubble up error messages in status server.
authored
101
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored
102 FileHandler *CreateFromDescriptor(int filedes, const std::string &cfg_dir,
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
103 const char *fs_path,
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
104 const std::string &underlying_file);
8268c37 @hzeller o Bubble up error messages in status server.
authored
105
a90d922 @hzeller o Separate sanitizing of config subdirectories.
authored
106 // Sanitize path to configuration subdirectory. Checks if someone tries
107 // to break out of the given base directory.
108 // Return if this is a sane directory.
109 // Passes the sanitized directory in the parameter.
110 bool SanitizeConfigSubdir(std::string *subdir_path) const;
111
112 // List available config directories; if "warn_invalid" is true,
113 // non-directories or symbolic links breaking out of the directory are
114 // reported.
115 const std::set<std::string> ListConfigDirs(bool warn_invalid) const;
116
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
117 std::string underlying_dir_;
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored
118 std::string base_config_dir_;
119 std::string current_config_subdir_;
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
120 bool debug_ui_enabled_;
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
121 bool gapless_processing_;
b5c1e96 @hzeller o more useful output on status server.
authored
122 FileHandlerCache open_file_cache_;
123 int total_file_openings_;
124 int total_file_reopen_;
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
125 };
126
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
127 #endif // FOLVE_FILESYSTEM_H
Something went wrong with that request. Please try again.