PFile.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PapillonCommon.h>
17 
18 PAPILLON_BEGIN_NAMESPACE
19 
20 class PDateTime;
21 
29 class PAPILLON_API_CORE PFile
30 {
31 public:
35  static PString RandomFilename();
36 
41  static PString RandomFilename(const PString& prefix, const PString& suffixOrExtension, bool inTemp = true);
42 
47  static PResult Copy(const PString& sourceFilename, const PString& destinationFilename, bool overwriteIfExists = false);
48 
53  static PResult Zip(const PString& sourceFilename, const PString& destinationFilename, bool overwriteIfExists = false);
54 
59  static PResult Unzip(const PString& sourceFilename, const PString& destinationFilename, bool overwriteIfExists = false);
60 
65  static PResult Remove(const PString& filename);
66 
71  static PResult Rename(const PString& oldName, const PString& newName);
72 
95  static PResult CheckExistsAndIsReadable(const PString& filename, papillon::int32 checkForGenericFile = -1);
96 
102  static PResult CheckExistsAndIsExecutable(const PString& filename);
103 
110  static bool Exists(const PString& filename);
111 
118  static bool IsReadable(const PString& filename);
119 
123  static bool IsWritable(const PString& filename);
124 
128  static bool IsExecutable(const PString& filename);
129 
133  static papillon::int64 GetSize(const PString& filename);
134 
138  static PDateTime GetLastModified(const PString& filename);
139 
143  static PString GetFilenameWithoutPath(const PString& filename);
144 
153  static PString GetAbsolutePath(const PString& filename);
154 
163  static PString GetAbsoluteFilePath(const PString& filename);
164 
171  static PString GetMD5(const PString& filename);
172 
178  static PString MD5(const PString& filename);
179 
180 private:
181  PFile();
182 };
183 
184 PAPILLON_END_NAMESPACE
185 
The PString class provides an Unicode character strings.
Definition: PString.h:37
The PDateTime class provides date and time functions, including time-zone management and UTC conversi...
Definition: PDateTime.h:38
The PResult class represents the result returned by most of Papillon functions; this class is used to...
Definition: PResult.h:159
The PFile class is an helper class for file management.
Definition: PFile.h:29