Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
real_directory.cpp
Go to the documentation of this file.
1 /* Copyright (c) 2010 Wildfire Games
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #include "precompiled.h"
25 
26 #include "lib/sysdep/filesystem.h"
27 #include "lib/file/file.h"
28 #include "lib/file/io/io.h"
29 
30 
31 RealDirectory::RealDirectory(const OsPath& path, size_t priority, size_t flags)
32  : m_path(path), m_priority(priority), m_flags(flags)
33 {
34 }
35 
36 
37 /*virtual*/ size_t RealDirectory::Precedence() const
38 {
39  return 1u;
40 }
41 
42 
43 /*virtual*/ wchar_t RealDirectory::LocationCode() const
44 {
45  return 'F';
46 }
47 
48 
49 /*virtual*/ Status RealDirectory::Load(const OsPath& name, const shared_ptr<u8>& buf, size_t size) const
50 {
51  return io::Load(m_path / name, buf.get(), size);
52 }
53 
54 
55 Status RealDirectory::Store(const OsPath& name, const shared_ptr<u8>& fileContents, size_t size)
56 {
57  return io::Store(m_path / name, fileContents.get(), size);
58 }
59 
60 
62 {
63  if(!m_watch)
65 }
66 
67 
68 PRealDirectory CreateRealSubdirectory(const PRealDirectory& realDirectory, const OsPath& subdirectoryName)
69 {
70  const OsPath path = realDirectory->Path() / subdirectoryName/"";
71  return PRealDirectory(new RealDirectory(path, realDirectory->Priority(), realDirectory->Flags()));
72 }
Status Store(const OsPath &name, const shared_ptr< u8 > &fileContents, size_t size)
static Status Store(const OsPath &pathname, const void *data, size_t size, const Parameters &p=Parameters(), const CompletedHook &completedHook=CompletedHook(), const IssueHook &issueHook=IssueHook())
Definition: io.h:298
LIB_API Status dir_watch_Add(const OsPath &path, PDirWatch &dirWatch)
start watching a single directory for changes.
Definition: dir_watch.cpp:28
virtual size_t Precedence() const
virtual wchar_t LocationCode() const
PDirWatch m_watch
PRealDirectory CreateRealSubdirectory(const PRealDirectory &realDirectory, const OsPath &subdirectoryName)
Definition: path.h:75
shared_ptr< RealDirectory > PRealDirectory
virtual Status Load(const OsPath &name, const shared_ptr< u8 > &buf, size_t size) const
const OsPath m_path
static Status Load(const OsPath &pathname, void *buf, size_t size, const Parameters &p=Parameters(), const CompletedHook &completedHook=CompletedHook(), const IssueHook &issueHook=IssueHook())
Definition: io.h:337
RealDirectory(const OsPath &path, size_t priority, size_t flags)
i64 Status
Error handling system.
Definition: status.h:171
Path()
Definition: path.h:80