94
95
And as the auto-conversation converts a 'unsigned long *' to a 'bool'
95
96
instead of 'unsigned long long *' we need to provide this explicitely -
96
97
otherwise applications magically start to fail… */
97
__deprecated bool Read(void *To,unsigned long long Size,unsigned long *Actual)
98
bool Read(void *To,unsigned long long Size,unsigned long *Actual) APT_DEPRECATED
99
100
unsigned long long R;
100
101
bool const T = Read(To, Size, &R);
105
bool Open(std::string FileName,unsigned int const Mode,CompressMode Compress,unsigned long const Perms = 0666);
106
bool Open(std::string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor,unsigned long const Perms = 0666);
107
inline bool Open(std::string const &FileName,unsigned int const Mode, unsigned long const Perms = 0666) {
108
return Open(FileName, Mode, None, Perms);
106
bool Open(std::string FileName,unsigned int const Mode,CompressMode Compress,unsigned long const AccessMode = 0666);
107
bool Open(std::string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor,unsigned long const AccessMode = 0666);
108
inline bool Open(std::string const &FileName,unsigned int const Mode, unsigned long const AccessMode = 0666) {
109
return Open(FileName, Mode, None, AccessMode);
110
111
bool OpenDescriptor(int Fd, unsigned int const Mode, CompressMode Compress, bool AutoClose=false);
111
112
bool OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration::Compressor const &compressor, bool AutoClose=false);
118
119
// Simple manipulators
119
120
inline int Fd() {return iFd;};
120
121
inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);};
121
__deprecated gzFile gzFd();
122
gzFile gzFd() APT_DEPRECATED APT_PURE;
123
124
inline bool IsOpen() {return iFd >= 0;};
124
125
inline bool Failed() {return (Flags & Fail) == Fail;};
128
129
inline bool IsCompressed() {return (Flags & Compressed) == Compressed;};
129
130
inline std::string &Name() {return FileName;};
131
FileFd(std::string FileName,unsigned int const Mode,unsigned long Perms = 0666) : iFd(-1), Flags(0), d(NULL)
132
FileFd(std::string FileName,unsigned int const Mode,unsigned long AccessMode = 0666) : iFd(-1), Flags(0), d(NULL)
133
Open(FileName,Mode, None, Perms);
134
Open(FileName,Mode, None, AccessMode);
135
FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long Perms = 0666) : iFd(-1), Flags(0), d(NULL)
136
FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long AccessMode = 0666) : iFd(-1), Flags(0), d(NULL)
137
Open(FileName,Mode, Compress, Perms);
138
Open(FileName,Mode, Compress, AccessMode);
139
140
FileFd() : iFd(-1), Flags(AutoClose), d(NULL) {};
140
141
FileFd(int const Fd, unsigned int const Mode = ReadWrite, CompressMode Compress = None) : iFd(-1), Flags(0), d(NULL)
151
152
FileFdPrivate* d;
152
bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor);
153
APT_HIDDEN bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor);
154
155
// private helpers to set Fail flag and call _error->Error
155
bool FileFdErrno(const char* Function, const char* Description,...) __like_printf(3) __cold;
156
bool FileFdError(const char* Description,...) __like_printf(2) __cold;
156
APT_HIDDEN bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD;
157
APT_HIDDEN bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD;
159
160
bool RunScripts(const char *Cnf);
161
162
int GetLock(std::string File,bool Errors = true);
162
163
bool FileExists(std::string File);
163
164
bool RealFileExists(std::string File);
164
bool DirectoryExists(std::string const &Path) __attrib_const;
165
bool DirectoryExists(std::string const &Path) APT_CONST;
165
166
bool CreateDirectory(std::string const &Parent, std::string const &Path);
166
167
time_t GetModificationTime(std::string const &Path);
168
bool Rename(std::string From, std::string To);
168
170
std::string GetTempDir();