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 1
00067 # define RECLS_VER_H_RECLSPP_FILEENTRY_REVISION 3
00068 # define RECLS_VER_H_RECLSPP_FILEENTRY_EDIT 11
00069 #endif
00070
00075
00076
00077
00078
00079 #include "reclspp.h"
00080 #include <recls_assert.h>
00081
00082
00083
00084
00085
00086 #if !defined(RECLS_NO_NAMESPACE)
00087 namespace recls
00088 {
00089
00090 namespace cpp
00091 {
00092 #endif
00093
00094
00095
00096
00097
00098 class FileEntry;
00099 class FileSearch;
00100
00101
00102
00103
00104
00108 class DirectoryParts
00109 {
00110
00111 private:
00112 friend class FileEntry;
00113 DirectoryParts(recls_info_t info);
00114
00117 public:
00119 DirectoryParts();
00121 DirectoryParts(DirectoryParts const &rhs);
00123 ~DirectoryParts();
00124
00126 DirectoryParts &operator =(DirectoryParts const &rhs);
00127
00129
00132 public:
00134 size_t size() const;
00140 string_t operator [](size_t index) const;
00141
00143
00144
00145 private:
00146 static recls_info_t _copy_info(recls_info_t info);
00147
00148
00149 private:
00150 recls_info_t m_info;
00151 };
00152
00156 class FileEntry
00157 {
00158
00159 private:
00160 friend class FileSearch;
00161 FileEntry(recls_info_t info);
00162
00165 public:
00167 FileEntry();
00169 FileEntry(FileEntry const &rhs);
00171 ~FileEntry();
00172
00174 FileEntry &operator =(FileEntry const &rhs);
00175
00177
00180 public:
00182 struct boolean
00183 {};
00184
00186 operator boolean *() const;
00187
00189
00192 public:
00194 char const *c_str() const;
00195
00197 string_t GetPath() const;
00198 #ifdef RECLS_PLATFORM_API_WIN32
00199
00200 char GetDrive() const;
00201 #endif
00202
00203 string_t GetDirectory() const;
00205 string_t GetDirectoryPath() const;
00207 DirectoryParts GetDirectoryParts() const;
00209 string_t GetFile() const;
00213 string_t GetShortFile() const;
00215 string_t GetFileName() const;
00217 string_t GetFileExt() const;
00218
00222 recls_time_t GetCreationTime() const;
00224 recls_time_t GetModificationTime() const;
00226 recls_time_t GetLastAccessTime() const;
00230 recls_time_t GetLastStatusChangeTime() const;
00231
00233 recls_filesize_t GetSize() const;
00234
00236 recls_bool_t IsReadOnly() const;
00238 recls_bool_t IsDirectory() const;
00240 recls_bool_t IsLink() const;
00241
00243
00244
00245 private:
00246 static recls_info_t _copy_info(recls_info_t info);
00247
00248
00249 private:
00250 recls_info_t m_info;
00251 };
00252
00253
00254
00255
00256
00267 inline char const *c_str_ptr(FileEntry const &fe)
00268 {
00269 return fe.c_str();
00270 }
00271
00272
00273
00274
00275
00276 inline recls_info_t DirectoryParts::_copy_info(recls_info_t info)
00277 {
00278 recls_info_t newInfo;
00279
00280 if( NULL == info ||
00281 RECLS_FAILED(Recls_CopyDetails(info, &newInfo)))
00282 {
00283 newInfo = NULL;
00284 }
00285
00286 return newInfo;
00287 }
00288
00289 inline DirectoryParts::DirectoryParts(recls_info_t info)
00290 : m_info(_copy_info(info))
00291 {}
00292
00293 inline DirectoryParts::DirectoryParts()
00294 : m_info(NULL)
00295 {}
00296
00297 inline DirectoryParts::DirectoryParts(DirectoryParts const &rhs)
00298 : m_info(_copy_info(rhs.m_info))
00299 {}
00300
00301 inline DirectoryParts::~DirectoryParts()
00302 {
00303 Recls_CloseDetails(m_info);
00304 }
00305
00306 inline DirectoryParts &DirectoryParts::operator =(DirectoryParts const &rhs)
00307 {
00308 Recls_CloseDetails(m_info);
00309
00310 m_info = _copy_info(rhs.m_info);
00311
00312 return *this;
00313 }
00314
00315 inline size_t DirectoryParts::size() const
00316 {
00317 return Recls_GetDirectoryPartProperty(m_info, -1, NULL, 0);
00318 }
00319
00320 inline string_t DirectoryParts::operator [](size_t index) const
00321 {
00322 char dirPart[RECLS_PATH_MAX];
00323
00324 recls_assert(NULL != m_info);
00325 recls_assert(index < size());
00326
00327 return RECLS_SUCCEEDED(Recls_GetDirectoryPartProperty(m_info, index, dirPart, RECLS_PATH_MAX)) ? string_t(dirPart) : string_t();
00328 }
00329
00330 inline recls_info_t FileEntry::_copy_info(recls_info_t info)
00331 {
00332 recls_info_t newInfo;
00333
00334 if( NULL == info ||
00335 RECLS_FAILED(Recls_CopyDetails(info, &newInfo)))
00336 {
00337 newInfo = NULL;
00338 }
00339
00340 return newInfo;
00341 }
00342
00343 inline FileEntry::FileEntry(recls_info_t info)
00344 : m_info(info)
00345 {}
00346
00347 inline FileEntry::FileEntry()
00348 : m_info(NULL)
00349 {}
00350
00351 inline FileEntry::FileEntry(FileEntry const &rhs)
00352 : m_info(_copy_info(rhs.m_info))
00353 {}
00354
00355 inline FileEntry::~FileEntry()
00356 {
00357 Recls_CloseDetails(m_info);
00358 }
00359
00360 inline FileEntry &FileEntry::operator =(FileEntry const &rhs)
00361 {
00362 Recls_CloseDetails(m_info);
00363
00364 m_info = _copy_info(rhs.m_info);
00365
00366 return *this;
00367 }
00368
00369 inline FileEntry::operator FileEntry::boolean *() const
00370 {
00371 return static_cast<boolean*>(0) + (NULL != m_info);
00372 }
00373
00374 inline char const *FileEntry::c_str() const
00375 {
00376 return (NULL != m_info) ? m_info->path.begin : "";
00377 }
00378
00379 inline string_t FileEntry::GetPath() const
00380 {
00381 recls_assert(NULL != m_info);
00382
00383 return string_t(m_info->path.begin, m_info->path.end);
00384 }
00385
00386 #ifdef RECLS_PLATFORM_API_WIN32
00387 inline char FileEntry::GetDrive() const
00388 {
00389 char chDrive;
00390
00391 return (Recls_GetDriveProperty(m_info, &chDrive), chDrive);
00392 }
00393 #endif
00394
00395 inline string_t FileEntry::GetDirectory() const
00396 {
00397 recls_assert(NULL != m_info);
00398
00399 return string_t(m_info->directory.begin, m_info->directory.end);
00400 }
00401
00402 inline string_t FileEntry::GetDirectoryPath() const
00403 {
00404 recls_assert(NULL != m_info);
00405
00406 return string_t(m_info->path.begin, m_info->directory.end);
00407 }
00408
00409 inline DirectoryParts FileEntry::GetDirectoryParts() const
00410 {
00411 recls_assert(NULL != m_info);
00412
00413 return DirectoryParts(m_info);
00414 }
00415
00416 inline string_t FileEntry::GetFile() const
00417 {
00418 recls_assert(NULL != m_info);
00419
00420 return string_t(m_info->fileName.begin, m_info->fileExt.end);
00421 }
00422
00423 inline string_t FileEntry::GetShortFile() const
00424 {
00425 #ifdef RECLS_PLATFORM_API_WIN32
00426 recls_assert(NULL != m_info);
00427
00428 return string_t(m_info->shortFile.begin, m_info->shortFile.end);
00429 #else
00430 return GetFile();
00431 #endif
00432 }
00433
00434 inline string_t FileEntry::GetFileName() const
00435 {
00436 recls_assert(NULL != m_info);
00437
00438 return string_t(m_info->fileName.begin, m_info->fileName.end);
00439 }
00440
00441 inline string_t FileEntry::GetFileExt() const
00442 {
00443 recls_assert(NULL != m_info);
00444
00445 return string_t(m_info->fileExt.begin, m_info->fileExt.end);
00446 }
00447
00448 inline recls_time_t FileEntry::GetCreationTime() const
00449 {
00450 recls_assert(NULL != m_info);
00451
00452 return Recls_GetCreationTime(m_info);
00453 }
00454
00455 inline recls_time_t FileEntry::GetModificationTime() const
00456 {
00457 recls_assert(NULL != m_info);
00458
00459 return Recls_GetModificationTime(m_info);
00460 }
00461
00462 inline recls_time_t FileEntry::GetLastAccessTime() const
00463 {
00464 recls_assert(NULL != m_info);
00465
00466 return Recls_GetLastAccessTime(m_info);
00467 }
00468
00469 inline recls_time_t FileEntry::GetLastStatusChangeTime() const
00470 {
00471 recls_assert(NULL != m_info);
00472
00473 return Recls_GetLastStatusChangeTime(m_info);
00474 }
00475
00476 inline recls_filesize_t FileEntry::GetSize() const
00477 {
00478 recls_assert(NULL != m_info);
00479
00480 return m_info->size;
00481 }
00482
00483 inline recls_bool_t FileEntry::IsReadOnly() const
00484 {
00485 recls_assert(NULL != m_info);
00486
00487 return Recls_IsFileReadOnly(m_info);
00488 }
00489
00490 inline recls_bool_t FileEntry::IsDirectory() const
00491 {
00492 recls_assert(NULL != m_info);
00493
00494 return Recls_IsFileDirectory(m_info);
00495 }
00496
00497 inline recls_bool_t FileEntry::IsLink() const
00498 {
00499 recls_assert(NULL != m_info);
00500
00501 return Recls_IsFileLink(m_info);
00502 }
00503
00504
00505
00506
00507
00508 #if !defined(RECLS_NO_NAMESPACE)
00509 }
00510 }
00511 #endif
00512
00513
00514
00515
00516
00517