~ubuntu-branches/ubuntu/trusty/apt/trusty

« back to all changes in this revision

Viewing changes to apt-pkg/contrib/fileutl.h

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2014-04-01 17:48:58 UTC
  • mfrom: (1.4.87 sid)
  • Revision ID: package-import@ubuntu.com-20140401174858-4mv29mm29zu22fn1
Tags: 1.0.1ubuntu1
merge with the debian/sid 1.0.1 version
(LP: #1302033)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <string>
28
28
#include <vector>
29
29
#include <set>
 
30
#include <time.h>
30
31
 
31
32
#include <zlib.h>
32
33
 
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
98
99
   {
99
100
        unsigned long long R;
100
101
        bool const T = Read(To, Size, &R);
102
103
        return T;
103
104
   }
104
105
 
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);
109
110
   };
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;
122
123
 
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;};
130
131
   
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)
132
133
   {
133
 
      Open(FileName,Mode, None, Perms);
 
134
      Open(FileName,Mode, None, AccessMode);
134
135
   };
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)
136
137
   {
137
 
      Open(FileName,Mode, Compress, Perms);
 
138
      Open(FileName,Mode, Compress, AccessMode);
138
139
   };
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)
149
150
 
150
151
   private:
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);
153
154
 
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;
157
158
};
158
159
 
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);
167
169
 
168
170
std::string GetTempDir();
169
171