Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (86 sloc) 3.898 kb
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
1 // -*- c++ -*-
2 // Copyright (C) 2012 Henner Zeller <h.zeller@acm.org>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
17 #ifndef FOLVE_FILESYSTEM_H
18 #define FOLVE_FILESYSTEM_H
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
19
20 #include <unistd.h>
21
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
22 #include <string>
23 #include <vector>
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
24 #include <set>
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
25
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
26 #include "file-handler-cache.h"
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
27 #include "file-handler.h"
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
28
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
29 #ifndef FOLVE_VERSION
30 #define FOLVE_VERSION "[unknown version - compile from git]"
31 #endif
32
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
33 class FolveFilesystem {
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
34 public:
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
35 // Create a new filesystem. At least SetBasedir() needs to be called
36 // for this to be properly initialized.
37 FolveFilesystem();
38
39 // Underlying directory - the directory we read files from.
40 void set_underlying_dir(const std::string &dir) { underlying_dir_ = dir; }
41 const std::string &underlying_dir() const { return underlying_dir_; }
42
43 // Config directories contain the filter configurations.
44 void add_config_dir(const char *config_dir) {
45 config_dirs_.push_back(config_dir);
46 }
47 const std::vector<std::string> &config_dirs() const { return config_dirs_; }
48
49 // Switch the current config to i. Values out of range are not accepted.
50 void SwitchCurrentConfigIndex(int i);
51 int current_cfg_index() const { return current_cfg_index_; }
52
53 // Check if properly initialized. Return 'false' if not and print a message
54 // to stderr.
55 bool CheckInitialized();
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
56
0aee3bb @hzeller o Show base dir that is mounted.
authored
57 // Create a new filter given the filesystem path and the underlying
58 // path.
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
59 // Returns NULL, if it cannot be created.
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
60 FileHandler *GetOrCreateHandler(const char *fs_path);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
61
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
62 // Inform filesystem that this file handler is not needed anymore
63 // (FS still might consider keeping it around for a while).
64 void Close(const char *fs_path, const FileHandler *handler);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
65
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
66 // Return dynamic size of file.
67 int StatByFilename(const char *fs_path, struct stat *st);
68
ac40d85 @hzeller o Make sure we match the alphabetically next file with
authored
69 // List files in given filesystem directory that match the suffix.
70 // Returns a set of filesystem paths of existing files.
71 // (We don't want globbing as filenames might contain weird characters).
72 bool ListDirectory(const std::string &fs_dir, const std::string &suffix,
73 std::set<std::string> *files);
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
74
b5c1e96 @hzeller o more useful output on status server.
authored
75 FileHandlerCache *handler_cache() { return &open_file_cache_; }
0aee3bb @hzeller o Show base dir that is mounted.
authored
76
5830c5a @hzeller o Switch logging to syslog()
authored
77 // Sets more fine grained debug log messages.
78 void SetDebugMode(bool b);
79 bool IsDebugMode() const;
80
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
81 void set_debug_ui_enabled(bool b) { debug_ui_enabled_ = b; }
82 bool is_debug_ui_enabled() const { return debug_ui_enabled_; }
83
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
84 void set_gapless_processing(bool b) { gapless_processing_ = b; }
85 bool gapless_processing() const { return gapless_processing_; }
86
0aee3bb @hzeller o Show base dir that is mounted.
authored
87 // Some stats.
b5c1e96 @hzeller o more useful output on status server.
authored
88 int total_file_openings() { return total_file_openings_; }
89 int total_file_reopen() { return total_file_reopen_; }
90
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
91 private:
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
92 // Get cache key, depending on the given configuration.
93 std::string CacheKey(int config_idx, const char *fs_path);
8268c37 @hzeller o Bubble up error messages in status server.
authored
94
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
95 FileHandler *CreateFromDescriptor(int filedes, int cfg_idx,
96 const char *fs_path,
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
97 const std::string &underlying_file);
8268c37 @hzeller o Bubble up error messages in status server.
authored
98
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
99 std::string underlying_dir_;
100 std::vector<std::string> config_dirs_;
101 int current_cfg_index_;
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
102 bool debug_ui_enabled_;
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
103 bool gapless_processing_;
b5c1e96 @hzeller o more useful output on status server.
authored
104 FileHandlerCache open_file_cache_;
105 int total_file_openings_;
106 int total_file_reopen_;
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
107 };
108
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
109 #endif // FOLVE_FILESYSTEM_H
Something went wrong with that request. Please try again.