~ubuntu-branches/ubuntu/maverick/znc/maverick

« back to all changes in this revision

Viewing changes to FileUtils.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2010-05-24 18:05:44 UTC
  • mfrom: (1.3.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100524180544-8e4s3f4nj0lhyw7n
Tags: 0.090~rc1-1
* New upstream release candidate.
  - Drop znc-webadmin package. It is now provided in the core source code.
  - Rename discon_kick module to disconkick.
  - Add charset and notes module.
* Add missing dependency on libc-ares-dev to znc-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        bool IsSock(bool bUseLstat = false) const;
54
54
 
55
55
        // for gettin file types, using fstat instead
56
 
        static bool FType(const CString sFileName, EFileTypes eType, bool bUseLstat = false);
 
56
        static bool FType(const CString& sFileName, EFileTypes eType, bool bUseLstat = false);
57
57
 
58
58
        enum EFileAttr {
59
59
                FA_Name,
122
122
        // flock() wrapper
123
123
        bool Lock(int iOperation);
124
124
 
125
 
        CString m_sBuffer;
126
 
        int             m_iFD;
 
125
        CString m_sBuffer;
 
126
        int     m_iFD;
127
127
 
128
128
protected:
129
 
        CString m_sLongName;    //!< Absolute filename (m_sPath + "/" + m_sShortName)
130
 
        CString m_sShortName;   //!< Filename alone, without path
 
129
        CString m_sLongName;  //!< Absolute filename (m_sPath + "/" + m_sShortName)
 
130
        CString m_sShortName; //!< Filename alone, without path
131
131
};
132
132
 
133
133
class CDir : public vector<CFile*> {
160
160
                return FillByWildcard(sDir, "*");
161
161
        }
162
162
 
163
 
/*      static bool Create(const CString& sDir, mode_t mode = 0755) {
164
 
                VCCString vSubDirs = sDir.split("[/\\\\]+");
165
 
                CCString sCurDir;
166
 
 
167
 
                for (unsigned int a = 0; a < vSubDirs.size(); a++) {
168
 
                        sCurDir += vSubDirs[a] + "/";
169
 
                        if ((!CDir::Exists(sCurDir)) && (mkdir(sCurDir.c_str(), mode) != 0)) {
170
 
                                return false;
171
 
                        }
172
 
                }
173
 
 
174
 
                return true;
175
 
        }
176
 
 
177
 
        int FillByRegex(const CCString& sDir, const CCString& sRegex, const CCString& sFlags = "") {
178
 
                CleanUp();
179
 
                DIR* dir = opendir((sDir.empty()) ? "." : sDir.c_str());
180
 
 
181
 
                if (!dir) {
182
 
                        return 0;
183
 
                }
184
 
 
185
 
                struct dirent * de;
186
 
 
187
 
                while ((de = readdir(dir)) != 0) {
188
 
                        if ((strcmp(de->d_name, ".") == 0) || (strcmp(de->d_name, "..") == 0)) {
189
 
                                continue;
190
 
                        }
191
 
                        if ((!sRegex.empty()) && (!CCString::search(de->d_name, sRegex, sFlags))) {
192
 
                                continue;
193
 
                        }
194
 
 
195
 
                        CFile *file = new CFile(sDir, de->d_name, this);
196
 
                        push_back(file);
197
 
                }
198
 
 
199
 
                closedir(dir);
200
 
                return size();
201
 
        }*/
202
 
 
203
163
        int FillByWildcard(const CString& sDir, const CString& sWildcard) {
204
164
                CleanUp();
205
165
                DIR* dir = opendir((sDir.empty()) ? "." : sDir.c_str());
218
178
                                continue;
219
179
                        }
220
180
 
221
 
                        CFile *file = new CFile(sDir + "/" + de->d_name/*, this*/);     // @todo need to pass pointer to 'this' if we want to do Sort()
 
181
                        CFile *file = new CFile(sDir + "/" + de->d_name/*, this*/); // @todo need to pass pointer to 'this' if we want to do Sort()
222
182
                        push_back(file);
223
183
                }
224
184
 
282
242
 
283
243
private:
284
244
protected:
285
 
        CFile::EFileAttr        m_eSortAttr;
286
 
        bool                            m_bDesc;
 
245
        CFile::EFileAttr m_eSortAttr;
 
246
        bool             m_bDesc;
287
247
};
288
248
 
289
249
//! @author imaginos@imaginos.net
316
276
        void close2(int iPid, int iReadFD, int iWriteFD);
317
277
 
318
278
private:
319
 
        int                     m_iPid;
 
279
        int  m_iPid;
320
280
};
321
281
#endif // !_FILEUTILS_H