2
* Copyright (C) 2016 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authors: Michi Henning <michi.henning@canonical.com>
21
#include <unity/storage/qt/client/Item.h>
39
namespace local_client
44
} // namespace local_client
46
namespace remote_client
51
} // namespace remotelocal_client
52
} // namespace internal
55
\brief Class that represents a file.
57
A file is a sequence of bytes.
59
class UNITY_STORAGE_EXPORT File final : public Item
67
File& operator=(File&&);
70
\brief Convenience type definition.
72
typedef std::shared_ptr<File> SPtr;
75
\brief Returns the size of the file in bytes.
76
\throws DestroyedException if the file has been destroyed.
81
\brief Creates an uploader for the file.
82
\param policy The conflict resolution policy. If set to ConflictPolicy::overwrite,
83
the contents of the file will be overwritten even if the file was modified
84
after this File instance was retrieved. Otherwise, if set to ConflictPolicy::error_if_conflict,
85
an attempt to retrieve the File instance from the future returned by Uploader::finish_upload()
86
throws ConflictException if the file was was modified via some other channel.
87
\param size The size of the upload in bytes.
88
\note The provided file size must match the number of bytes that you write for the upload, otherwise
89
an attampt to retrive the File instance from the future returned by Uploader::finish_upload()
90
throws LogicException.
92
QFuture<std::shared_ptr<Uploader>> create_uploader(ConflictPolicy policy, int64_t size);
95
\brief Creates a downloader for the file.
97
QFuture<std::shared_ptr<Downloader>> create_downloader();
100
File(internal::FileBase*) UNITY_STORAGE_HIDDEN;
102
friend class internal::local_client::FileImpl;
103
friend class internal::remote_client::FileImpl;
106
} // namespace client
108
} // namespace storage