Annotation of truecrypt/platform/filesystempath.h, revision 1.1.1.2

1.1       root        1: /*
                      2:  Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
                      3: 
1.1.1.2 ! root        4:  Governed by the TrueCrypt License 2.5 the full text of which is contained
1.1       root        5:  in the file License.txt included in TrueCrypt binary and source code
                      6:  distribution packages.
                      7: */
                      8: 
                      9: #ifndef TC_HEADER_Platform_FilesystemPath
                     10: #define TC_HEADER_Platform_FilesystemPath
                     11: 
                     12: #include "PlatformBase.h"
                     13: #include "SharedPtr.h"
                     14: #include "StringConverter.h"
                     15: 
                     16: namespace TrueCrypt
                     17: {
                     18:        struct FilesystemPathType
                     19:        {
                     20:                enum Enum
                     21:                {
                     22:                        Unknown,
                     23:                        File,
                     24:                        Directory,
                     25:                        SymbolickLink,
                     26:                        BlockDevice,
                     27:                        CharacterDevice
                     28:                };
                     29:        };
                     30: 
                     31:        class FilesystemPath 
                     32:        {
                     33:        public:
                     34:                FilesystemPath () { }
                     35:                FilesystemPath (const char *path) : Path (StringConverter::ToWide (path)) { }
                     36:                FilesystemPath (string path) : Path (StringConverter::ToWide (path)) { }
                     37:                FilesystemPath (const wchar_t *path) : Path (path) { }
                     38:                FilesystemPath (wstring path) : Path (path) { }
                     39:                virtual ~FilesystemPath () { }
                     40: 
                     41:                bool operator== (const FilesystemPath &other) const { return Path == other.Path; }
                     42:                bool operator!= (const FilesystemPath &other) const { return Path != other.Path; }
                     43:                operator string () const { return StringConverter::ToSingle (Path); }
                     44:                operator wstring () const { return Path; }
                     45: 
                     46:                void Delete () const;
                     47:                FilesystemPathType::Enum GetType () const;
                     48:                bool IsBlockDevice () const throw () { try { return GetType() == FilesystemPathType::BlockDevice; } catch (...) { return false; }; }
                     49:                bool IsCharacterDevice () const throw () { try { return GetType() == FilesystemPathType::CharacterDevice; } catch (...) { return false; }; }
                     50:                bool IsDevice () const throw () { return IsBlockDevice() || IsCharacterDevice(); }
                     51:                bool IsDirectory () const throw () { try { return GetType() == FilesystemPathType::Directory; } catch (...) { return false; } }
                     52:                bool IsEmpty () const throw () { try { return Path.empty(); } catch (...) { return false; } }
                     53:                bool IsFile () const throw () { try { return GetType() == FilesystemPathType::File; } catch (...) { return false; } }
                     54: 
                     55:                static const int MaxSize = 260;
                     56: 
                     57:        protected:
                     58:                wstring Path;
                     59:        };
                     60: 
                     61:        typedef FilesystemPath DevicePath;
                     62:        typedef FilesystemPath DirectoryPath;
                     63:        typedef FilesystemPath FilePath;
                     64: 
                     65:        typedef list < shared_ptr <DirectoryPath> > DirectoryPathList;
                     66:        typedef list < shared_ptr <FilePath> > FilePathList;
                     67: }
                     68: 
                     69: #endif // TC_HEADER_Platform_FilesystemPath

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.