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 3
00067 # define RECLS_VER_H_RECLSPP_FILEENTRY_REVISION 4
00068 # define RECLS_VER_H_RECLSPP_FILEENTRY_EDIT 18
00069 #endif
00070
00075
00076
00077
00078
00079 #include "reclspp.h"
00080 #include <recls_assert.h>
00081 #include <stlsoft_operator_bool.h>
00082
00083
00084
00085
00086
00087 #if !defined(RECLS_NO_NAMESPACE)
00088 namespace recls
00089 {
00090
00091 namespace cpp
00092 {
00093 #endif
00094
00095
00096
00097
00098
00099 class FileEntry;
00100 class FileSearch;
00101
00102
00103
00104
00105
00109 class DirectoryParts
00110 {
00111 public:
00112 typedef recls_char_t char_type;
00113 typedef DirectoryParts class_type;
00114
00115
00116 private:
00117 friend class FileEntry;
00118 DirectoryParts(recls_info_t info);
00119
00122 public:
00124 DirectoryParts();
00126 DirectoryParts(DirectoryParts const &rhs);
00128 ~DirectoryParts();
00129
00131 DirectoryParts &operator =(DirectoryParts const &rhs);
00132
00134
00137 public:
00139 size_t size() const;
00145 string_t operator [](size_t index) const;
00146
00148
00149
00150 private:
00151 static recls_info_t _copy_info(recls_info_t info);
00152
00153
00154 private:
00155 recls_info_t m_info;
00156 };
00157
00161 class FileEntry
00162 {
00163 public:
00164 typedef recls_char_t char_type;
00165 typedef FileEntry class_type;
00166
00167
00168 private:
00169 friend class FileSearch;
00170 FileEntry(recls_info_t info);
00171
00174 public:
00176 FileEntry();
00178 FileEntry(FileEntry const &rhs);
00180 ~FileEntry();
00181
00183 FileEntry &operator =(FileEntry const &rhs);
00184
00186
00189 private:
00190 STLSOFT_DEFINE_OPERATOR_BOOL_TYPES(class_type, boolean_generator_type, boolean_type);
00191 public:
00193 operator boolean_type() const
00194 {
00195 return boolean_generator_type::translate(NULL != m_info);
00196 }
00197
00198 #ifndef STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT
00199
00200 bool operator !() const;
00201 #endif
00202
00204
00207 public:
00209 char_type const *c_str() const;
00210
00212 string_t GetPath() const;
00213 #ifdef RECLS_PLATFORM_API_WIN32
00214
00215 char_type GetDrive() const;
00216 #endif
00217
00218 string_t GetDirectory() const;
00220 string_t GetDirectoryPath() const;
00222 DirectoryParts GetDirectoryParts() const;
00224 string_t GetFile() const;
00228 string_t GetShortFile() const;
00230 string_t GetFileName() const;
00232 string_t GetFileExt() const;
00233
00237 recls_time_t GetCreationTime() const;
00239 recls_time_t GetModificationTime() const;
00241 recls_time_t GetLastAccessTime() const;
00245 recls_time_t GetLastStatusChangeTime() const;
00246
00248 recls_filesize_t GetSize() const;
00249
00251 recls_bool_t IsReadOnly() const;
00253 recls_bool_t IsDirectory() const;
00255 recls_bool_t IsLink() const;
00256
00258
00259
00260 private:
00261 static recls_info_t _copy_info(recls_info_t info);
00262
00263
00264 private:
00265 recls_info_t m_info;
00266 };
00267
00268
00269
00270
00271
00282 inline FileEntry::char_type const *c_str_ptr(FileEntry const &fe)
00283 {
00284 return fe.c_str();
00285 }
00286
00287
00288
00289
00290
00291 inline recls_info_t DirectoryParts::_copy_info(recls_info_t info)
00292 {
00293 recls_info_t newInfo;
00294
00295 if( NULL == info ||
00296 RECLS_FAILED(Recls_CopyDetails(info, &newInfo)))
00297 {
00298 newInfo = NULL;
00299 }
00300
00301 return newInfo;
00302 }
00303
00304 inline DirectoryParts::DirectoryParts(recls_info_t info)
00305 : m_info(_copy_info(info))
00306 {}
00307
00308 inline DirectoryParts::DirectoryParts()
00309 : m_info(NULL)
00310 {}
00311
00312 inline DirectoryParts::DirectoryParts(DirectoryParts const &rhs)
00313 : m_info(_copy_info(rhs.m_info))
00314 {}
00315
00316 inline DirectoryParts::~DirectoryParts()
00317 {
00318 Recls_CloseDetails(m_info);
00319 }
00320
00321 inline DirectoryParts &DirectoryParts::operator =(DirectoryParts const &rhs)
00322 {
00323 Recls_CloseDetails(m_info);
00324
00325 m_info = _copy_info(rhs.m_info);
00326
00327 return *this;
00328 }
00329
00330 inline size_t DirectoryParts::size() const
00331 {
00332 return Recls_GetDirectoryPartProperty(m_info, -1, NULL, 0);
00333 }
00334
00335 inline string_t DirectoryParts::operator [](size_t index) const
00336 {
00337 char_type dirPart[RECLS_PATH_MAX];
00338
00339 recls_assert(NULL != m_info);
00340 recls_assert(index < size());
00341
00342 return RECLS_SUCCEEDED(Recls_GetDirectoryPartProperty(m_info, index, dirPart, RECLS_PATH_MAX)) ? string_t(dirPart) : string_t();
00343 }
00344
00345 inline recls_info_t FileEntry::_copy_info(recls_info_t info)
00346 {
00347 recls_info_t newInfo;
00348
00349 if( NULL == info ||
00350 RECLS_FAILED(Recls_CopyDetails(info, &newInfo)))
00351 {
00352 newInfo = NULL;
00353 }
00354
00355 return newInfo;
00356 }
00357
00358 inline FileEntry::FileEntry(recls_info_t info)
00359 : m_info(info)
00360 {}
00361
00362 inline FileEntry::FileEntry()
00363 : m_info(NULL)
00364 {}
00365
00366 inline FileEntry::FileEntry(FileEntry const &rhs)
00367 : m_info(_copy_info(rhs.m_info))
00368 {}
00369
00370 inline FileEntry::~FileEntry()
00371 {
00372 if(NULL != m_info)
00373 {
00374 Recls_CloseDetails(m_info);
00375 }
00376 }
00377
00378 inline FileEntry &FileEntry::operator =(FileEntry const &rhs)
00379 {
00380 Recls_CloseDetails(m_info);
00381
00382 m_info = _copy_info(rhs.m_info);
00383
00384 return *this;
00385 }
00386
00387 #ifndef STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT
00388 inline bool FileEntry::operator !() const
00389 {
00390 return (*this) ? false : true;
00391 }
00392 #endif
00393
00394
00395 inline FileEntry::char_type const *FileEntry::c_str() const
00396 {
00397 return (NULL != m_info) ? m_info->path.begin : "";
00398 }
00399
00400 inline string_t FileEntry::GetPath() const
00401 {
00402 recls_assert(NULL != m_info);
00403
00404 return string_t(m_info->path.begin, m_info->path.end);
00405 }
00406
00407 #ifdef RECLS_PLATFORM_API_WIN32
00408 inline FileEntry::char_type FileEntry::GetDrive() const
00409 {
00410 char_type chDrive;
00411
00412 return (Recls_GetDriveProperty(m_info, &chDrive), chDrive);
00413 }
00414 #endif
00415
00416 inline string_t FileEntry::GetDirectory() const
00417 {
00418 recls_assert(NULL != m_info);
00419
00420 return string_t(m_info->directory.begin, m_info->directory.end);
00421 }
00422
00423 inline string_t FileEntry::GetDirectoryPath() const
00424 {
00425 recls_assert(NULL != m_info);
00426
00427 return string_t(m_info->path.begin, m_info->directory.end);
00428 }
00429
00430 inline DirectoryParts FileEntry::GetDirectoryParts() const
00431 {
00432 recls_assert(NULL != m_info);
00433
00434 return DirectoryParts(m_info);
00435 }
00436
00437 inline string_t FileEntry::GetFile() const
00438 {
00439 recls_assert(NULL != m_info);
00440 recls_assert(m_info->fileName.begin <= m_info->fileExt.end);
00441
00442 return string_t(m_info->fileName.begin, m_info->fileExt.end);
00443 }
00444
00445 inline string_t FileEntry::GetShortFile() const
00446 {
00447 #ifdef RECLS_PLATFORM_API_WIN32
00448 recls_assert(NULL != m_info);
00449
00450 return string_t(m_info->shortFile.begin, m_info->shortFile.end);
00451 #else
00452 return GetFile();
00453 #endif
00454 }
00455
00456 inline string_t FileEntry::GetFileName() const
00457 {
00458 recls_assert(NULL != m_info);
00459
00460 return string_t(m_info->fileName.begin, m_info->fileName.end);
00461 }
00462
00463 inline string_t FileEntry::GetFileExt() const
00464 {
00465 recls_assert(NULL != m_info);
00466
00467 return string_t(m_info->fileExt.begin, m_info->fileExt.end);
00468 }
00469
00470 inline recls_time_t FileEntry::GetCreationTime() const
00471 {
00472 recls_assert(NULL != m_info);
00473
00474 return Recls_GetCreationTime(m_info);
00475 }
00476
00477 inline recls_time_t FileEntry::GetModificationTime() const
00478 {
00479 recls_assert(NULL != m_info);
00480
00481 return Recls_GetModificationTime(m_info);
00482 }
00483
00484 inline recls_time_t FileEntry::GetLastAccessTime() const
00485 {
00486 recls_assert(NULL != m_info);
00487
00488 return Recls_GetLastAccessTime(m_info);
00489 }
00490
00491 inline recls_time_t FileEntry::GetLastStatusChangeTime() const
00492 {
00493 recls_assert(NULL != m_info);
00494
00495 return Recls_GetLastStatusChangeTime(m_info);
00496 }
00497
00498 inline recls_filesize_t FileEntry::GetSize() const
00499 {
00500 recls_assert(NULL != m_info);
00501
00502 return m_info->size;
00503 }
00504
00505 inline recls_bool_t FileEntry::IsReadOnly() const
00506 {
00507 recls_assert(NULL != m_info);
00508
00509 return Recls_IsFileReadOnly(m_info);
00510 }
00511
00512 inline recls_bool_t FileEntry::IsDirectory() const
00513 {
00514 recls_assert(NULL != m_info);
00515
00516 return Recls_IsFileDirectory(m_info);
00517 }
00518
00519 inline recls_bool_t FileEntry::IsLink() const
00520 {
00521 recls_assert(NULL != m_info);
00522
00523 return Recls_IsFileLink(m_info);
00524 }
00525
00526
00527
00528
00529
00530 #if !defined(RECLS_NO_NAMESPACE)
00531 }
00532 }
00533 #endif
00534
00535
00536
00537
00538
00539