2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef FILESYSTEM_FILESYSTEM_MANAGER_H
18 #define FILESYSTEM_FILESYSTEM_MANAGER_H
26 #include "filesystem/filesystem_stat.h"
27 #include "filesystem/filesystem_utils.h"
29 #include "common/filesystem/filesystem_provider.h"
30 #include "common/filesystem/filesystem_storage.h"
33 namespace filesystem {
35 class FilesystemStateChangeListener {
37 virtual ~FilesystemStateChangeListener() {
39 virtual void onFilesystemStateChangeSuccessCallback(const common::Storage& storage) = 0;
40 virtual void onFilesystemStateChangeErrorCallback() = 0;
43 class FilesystemManager {
46 FilesystemStateChangeListener* listener_;
48 common::FilesystemProvider& fs_provider_;
51 virtual ~FilesystemManager();
53 static FilesystemManager& GetInstance();
55 void UnlinkFile(const std::string& path, const std::function<void()>& success_cb,
56 const std::function<void(FilesystemError)>& error_cb);
58 void StatPath(const std::string& path,
59 const std::function<void(const FilesystemStat&)>& success_cb,
60 const std::function<void(FilesystemError)>& error_cb);
62 void FetchStorages(const std::function<void(const common::Storages&)>& success_cb,
63 const std::function<void(FilesystemError)>& error_cb);
65 void FetchAllStorages(const std::function<void(const common::VirtualStorages&)>& success_cb,
66 const std::function<void(FilesystemError)>& error_cb);
68 void CreateFile(const std::string& path,
69 const std::function<void(const FilesystemStat&)>& success_cb,
70 const std::function<void(FilesystemError)>& error_cb);
72 void Rename(const std::string& oldPath, const std::string& newPath,
73 const std::function<void(const FilesystemStat&)>& success_cb,
74 const std::function<void(FilesystemError)>& error_cb);
76 void MakeDirectory(const std::string& path,
77 const std::function<void(FilesystemError)>& result_cb);
79 void ReadDir(const std::string& path,
80 const std::function<void(const std::vector<std::string>&)>& success_cb,
81 const std::function<void(FilesystemError)>& error_cb);
83 void RemoveDirectory(const std::string& path, const std::function<void()>& success_cb,
84 const std::function<void(FilesystemError)>& error_cb);
86 void CopyTo(const std::string& originFilePath, const std::string& destinationFilePath,
87 const bool overwrite, const std::function<void()>& success_cb,
88 const std::function<void(FilesystemError)>& error_cb);
90 void StartListening();
92 void OnStorageDeviceChanged(common::Storage const& _virtualStorage, common::StorageState _old,
93 common::StorageState _new);
94 void AddListener(FilesystemStateChangeListener* listener);
95 void RemoveListener();
97 void GetCanonicalPath(const std::string& path,
98 const std::function<void(const std::string&)>& success_cb,
99 const std::function<void(FilesystemError)>& error_cb);
101 } // namespace filesystem
102 } // namespace extension
104 #endif // FILESYSTEM_FILESYSTEM_MANAGER_H