00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00065 # define RECLS_VER_H_RECLSPP_FILEENTRY_MAJOR 1
00066 # define RECLS_VER_H_RECLSPP_FILEENTRY_MINOR 0
00067 # define RECLS_VER_H_RECLSPP_FILEENTRY_REVISION 8
00068 # define RECLS_VER_H_RECLSPP_FILEENTRY_EDIT 8
00069 #endif
00070
00073
00074
00075
00076
00077 #include "reclspp.h"
00078 #include "recls_assert.h"
00079
00080
00081
00082
00083
00084 #if !defined(RECLS_NO_NAMESPACE)
00085 namespace recls
00086 {
00087
00088 namespace cpp
00089 {
00090 #endif
00091
00092
00093
00094
00095
00096 class FileEntry;
00097 class FileSearch;
00098
00099
00100
00101
00102
00106 class DirectoryParts
00107 {
00108
00109 private:
00110 friend class FileEntry;
00111 DirectoryParts(recls_info_t info);
00112
00115 public:
00117 DirectoryParts();
00119 DirectoryParts(DirectoryParts const &rhs);
00121 ~DirectoryParts();
00122
00124 DirectoryParts &operator =(DirectoryParts const &rhs);
00125
00127
00130 public:
00132 size_t size() const;
00138 string_t operator [](size_t index) const;
00139
00141
00142
00143 private:
00144 static recls_info_t _copy_info(recls_info_t info);
00145
00146
00147 private:
00148 recls_info_t m_info;
00149 };
00150
00154 class FileEntry
00155 {
00156
00157 private:
00158 friend class FileSearch;
00159 FileEntry(recls_info_t info);
00160
00163 public:
00165 FileEntry();
00167 FileEntry(FileEntry const &rhs);
00169 ~FileEntry();
00170
00172 FileEntry &operator =(FileEntry const &rhs);
00173
00175
00178 public:
00180 struct boolean
00181 {};
00182
00184 operator boolean *() const;
00185
00187
00190 public:
00192 char const *c_str() const;
00193
00195 string_t GetPath() const;
00196 #ifdef RECLS_PLATFORM_API_WIN32
00197
00198 char GetDrive() const;
00199 #endif
00200
00201 string_t GetDirectory() const;
00203 DirectoryParts GetDirectoryParts() const;
00205 string_t GetFile() const;
00209 string_t GetShortFile() const;
00211 string_t GetFileName() const;
00213 string_t GetFileExt() const;
00214
00218 recls_time_t GetCreationTime() const;
00220 recls_time_t GetModificationTime() const;
00222 recls_time_t GetLastAccessTime() const;
00226 recls_time_t GetLastStatusChangeTime() const;
00227
00229 recls_filesize_t GetSize() const;
00230
00232 recls_bool_t IsReadOnly() const;
00234 recls_bool_t IsDirectory() const;
00236 recls_bool_t IsLink() const;
00237
00239
00240
00241 private:
00242 static recls_info_t _copy_info(recls_info_t info);
00243
00244
00245 private:
00246 recls_info_t m_info;
00247 };
00248
00249
00250
00251
00252
00261 inline char const *c_str_ptr(FileEntry const &fe)
00262 {
00263 return fe.c_str();
00264 }
00265
00266
00267
00268
00269
00270 inline recls_info_t DirectoryParts::_copy_info(recls_info_t info)
00271 {
00272 recls_info_t newInfo;
00273
00274 if( NULL == info ||
00275 RECLS_FAILED(Recls_CopyDetails(info, &newInfo)))
00276 {
00277 newInfo = NULL;
00278 }
00279
00280 return newInfo;
00281 }
00282
00283 inline DirectoryParts::DirectoryParts(recls_info_t info)
00284 : m_info(_copy_info(info))
00285 {}
00286
00287 inline DirectoryParts::DirectoryParts()
00288 : m_info(NULL)
00289 {}
00290
00291 inline DirectoryParts::DirectoryParts(DirectoryParts const &rhs)
00292 : m_info(_copy_info(rhs.m_info))
00293 {}
00294
00295 inline DirectoryParts::~DirectoryParts()
00296 {
00297 Recls_CloseDetails(m_info);
00298 }
00299
00300 inline DirectoryParts &DirectoryParts::operator =(DirectoryParts const &rhs)
00301 {
00302 Recls_CloseDetails(m_info);
00303
00304 m_info = _copy_info(rhs.m_info);
00305
00306 return *this;
00307 }
00308
00309 inline size_t DirectoryParts::size() const
00310 {
00311 return Recls_GetDirectoryPartProperty(m_info, -1, NULL, 0);
00312 }
00313
00314 inline string_t DirectoryParts::operator [](size_t index) const
00315 {
00316 char dirPart[RECLS_PATH_MAX];
00317
00318 recls_assert(NULL != m_info);
00319 recls_assert(index < size());
00320
00321 return RECLS_SUCCEEDED(Recls_GetDirectoryPartProperty(m_info, index, dirPart, RECLS_PATH_MAX)) ? string_t(dirPart) : string_t();
00322 }
00323
00324 inline recls_info_t FileEntry::_copy_info(recls_info_t info)
00325 {
00326 recls_info_t newInfo;
00327
00328 if( NULL == info ||
00329 RECLS_FAILED(Recls_CopyDetails(info, &newInfo)))
00330 {
00331 newInfo = NULL;
00332 }
00333
00334 return newInfo;
00335 }
00336
00337 inline FileEntry::FileEntry(recls_info_t info)
00338 : m_info(info)
00339 {}
00340
00341 inline FileEntry::FileEntry()
00342 : m_info(NULL)
00343 {}
00344
00345 inline FileEntry::FileEntry(FileEntry const &rhs)
00346 : m_info(_copy_info(rhs.m_info))
00347 {}
00348
00349 inline FileEntry::~FileEntry()
00350 {
00351 Recls_CloseDetails(m_info);
00352 }
00353
00354 inline FileEntry &FileEntry::operator =(FileEntry const &rhs)
00355 {
00356 Recls_CloseDetails(m_info);
00357
00358 m_info = _copy_info(rhs.m_info);
00359
00360 return *this;
00361 }
00362
00363 inline FileEntry::operator FileEntry::boolean *() const
00364 {
00365 return static_cast<boolean*>(0) + (NULL != m_info);
00366 }
00367
00368 inline char const *FileEntry::c_str() const
00369 {
00370 return (NULL != m_info) ? m_info->path.begin : "";
00371 }
00372
00373 inline string_t FileEntry::GetPath() const
00374 {
00375 recls_assert(NULL != m_info);
00376
00377 return string_t(m_info->path.begin, m_info->path.end);
00378 }
00379
00380 #ifdef RECLS_PLATFORM_API_WIN32
00381 inline char FileEntry::GetDrive() const
00382 {
00383 char chDrive;
00384
00385 return (Recls_GetDriveProperty(m_info, &chDrive), chDrive);
00386 }
00387 #endif
00388
00389 inline string_t FileEntry::GetDirectory() const
00390 {
00391 recls_assert(NULL != m_info);
00392
00393 return string_t(m_info->directory.begin, m_info->directory.end);
00394 }
00395
00396 inline DirectoryParts FileEntry::GetDirectoryParts() const
00397 {
00398 recls_assert(NULL != m_info);
00399
00400 return DirectoryParts(m_info);
00401 }
00402
00403 inline string_t FileEntry::GetFile() const
00404 {
00405 recls_assert(NULL != m_info);
00406
00407 return string_t(m_info->fileName.begin, m_info->fileExt.end);
00408 }
00409
00410 inline string_t FileEntry::GetShortFile() const
00411 {
00412 #ifdef RECLS_PLATFORM_API_WIN32
00413 recls_assert(NULL != m_info);
00414
00415 return string_t(m_info->shortFile.begin, m_info->shortFile.end);
00416 #else
00417 return GetFile();
00418 #endif
00419 }
00420
00421 inline string_t FileEntry::GetFileName() const
00422 {
00423 recls_assert(NULL != m_info);
00424
00425 return string_t(m_info->fileName.begin, m_info->fileName.end);
00426 }
00427
00428 inline string_t FileEntry::GetFileExt() const
00429 {
00430 recls_assert(NULL != m_info);
00431
00432 return string_t(m_info->fileExt.begin, m_info->fileExt.end);
00433 }
00434
00435 inline recls_time_t FileEntry::GetCreationTime() const
00436 {
00437 recls_assert(NULL != m_info);
00438
00439 return Recls_GetCreationTime(m_info);
00440 }
00441
00442 inline recls_time_t FileEntry::GetModificationTime() const
00443 {
00444 recls_assert(NULL != m_info);
00445
00446 return Recls_GetModificationTime(m_info);
00447 }
00448
00449 inline recls_time_t FileEntry::GetLastAccessTime() const
00450 {
00451 recls_assert(NULL != m_info);
00452
00453 return Recls_GetLastAccessTime(m_info);
00454 }
00455
00456 inline recls_time_t FileEntry::GetLastStatusChangeTime() const
00457 {
00458 recls_assert(NULL != m_info);
00459
00460 return Recls_GetLastStatusChangeTime(m_info);
00461 }
00462
00463 inline recls_filesize_t FileEntry::GetSize() const
00464 {
00465 recls_assert(NULL != m_info);
00466
00467 return m_info->size;
00468 }
00469
00470 inline recls_bool_t FileEntry::IsReadOnly() const
00471 {
00472 recls_assert(NULL != m_info);
00473
00474 return Recls_IsFileReadOnly(m_info);
00475 }
00476
00477 inline recls_bool_t FileEntry::IsDirectory() const
00478 {
00479 recls_assert(NULL != m_info);
00480
00481 return Recls_IsFileDirectory(m_info);
00482 }
00483
00484 inline recls_bool_t FileEntry::IsLink() const
00485 {
00486 recls_assert(NULL != m_info);
00487
00488 return Recls_IsFileLink(m_info);
00489 }
00490
00491
00492
00493
00494
00495 #if !defined(RECLS_NO_NAMESPACE)
00496 }
00497 }
00498 #endif
00499
00500
00501
00502
00503
00504