Repository navigation
Expand file tree
/
Copy pathFileOps.cpp
More file actions
177 lines (162 loc) · 4.82 KB
/
Copy pathFileOps.cpp
File metadata and controls
177 lines (162 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//-----------------------------------------------------------------------------
//
// FileOps.cpp
//
// Cross-platform File Operations
//
// Copyright (c) 2012 Greg Satz <satz@iranger.com>
// All rights reserved.
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#include <string>
#include "platform/FileOps.h"
#ifdef WIN32
#include "platform/windows/FileOpsImpl.h" // Platform-specific implementation of a File Operations
#elif defined WINRT
#include "platform/winRT/FileOpsImpl.h" // Platform-specific implementation of a File Operations
#else
#include "platform/unix/FileOpsImpl.h" // Platform-specific implementation of a File Operations
#endif
namespace OpenZWave
{
namespace Internal
{
namespace Platform
{
FileOps* FileOps::s_instance = NULL;
FileOpsImpl* FileOps::m_pImpl = NULL;
//-----------------------------------------------------------------------------
// <FileOps::Create>
// Static creation of the singleton
//-----------------------------------------------------------------------------
FileOps* FileOps::Create()
{
if (s_instance == NULL)
{
s_instance = new FileOps();
}
return s_instance;
}
//-----------------------------------------------------------------------------
// <FileOps::Destroy>
// Static method to destroy the fileops singleton.
//-----------------------------------------------------------------------------
void FileOps::Destroy()
{
delete s_instance;
s_instance = NULL;
}
//-----------------------------------------------------------------------------
// <FileOps::FolderExists>
// Static method to check for existance of a folder
//-----------------------------------------------------------------------------
bool FileOps::FolderExists(const string &_folderName)
{
if (s_instance != NULL)
{
return s_instance->m_pImpl->FolderExists(_folderName);
}
return false;
}
/**
* FileExists. Check for the existance of a file.
* \param string. file name.
* \return Bool value indicating existance.
*/
bool FileOps::FileExists(const string &_fileName)
{
if (s_instance != NULL)
{
return s_instance->m_pImpl->FileExists(_fileName);
}
return false;
}
/**
* FileWriteable. Check if we can write to a file.
* \param string. file name.
* \return Bool value indicating write permissions.
*/
bool FileOps::FileWriteable(const string &_fileName)
{
if (s_instance != NULL)
{
return s_instance->m_pImpl->FileWriteable(_fileName);
}
return false;
}
/**
* FileRotate. Rotate a File
* \param string. file name.
* \return Bool value indicating write permissions.
*/
bool FileOps::FileRotate(const string &_fileName)
{
if (s_instance != NULL)
{
return s_instance->m_pImpl->FileRotate(_fileName);
}
return false;
}
/**
* FileCopy. Copy a File
* \param string. source file name.
* \param string. destination file name
* \return Bool value indicating success.
*/
bool FileOps::FileCopy(const string &_fileName, const string &_destfileName)
{
if (s_instance != NULL)
{
return s_instance->m_pImpl->FileCopy(_fileName, _destfileName);
}
return false;
}
/**
* FolderCreate. Create a Folder
* \param string. folder name
* \return Bool value indicating success.
*/
bool FileOps::FolderCreate(const string &_folderName)
{
if (s_instance != NULL)
{
return s_instance->m_pImpl->FolderCreate(_folderName);
}
return false;
}
//-----------------------------------------------------------------------------
// <FileOps::FileOps>
// Constructor
//-----------------------------------------------------------------------------
FileOps::FileOps()
{
m_pImpl = new FileOpsImpl();
}
//-----------------------------------------------------------------------------
// <FileOps::~FileOps>
// Destructor
//-----------------------------------------------------------------------------
FileOps::~FileOps()
{
delete m_pImpl;
}
} // namespace Platform
} // namespace Internal
} // namespace OpenZWave