Adobe.com
Contents Suites Classes Class Index Member Index

IAIFilePath.hpp

Go to the documentation of this file.
00001 /*
00002  *        Name: IAIFilePath.hpp
00003  *     Purpose: C++ access class for File Path suite
00004  *
00005  * ADOBE SYSTEMS INCORPORATED
00006  * Copyright 2004-2007 Adobe Systems Incorporated.
00007  * All rights reserved.
00008  *
00009  * NOTICE:  Adobe permits you to use, modify, and distribute this file 
00010  * in accordance with the terms of the Adobe license agreement 
00011  * accompanying it. If you have received this file from a source other 
00012  * than Adobe, then your use, modification, or distribution of it 
00013  * requires the prior written permission of Adobe.
00014  *
00015  */
00016 
00017 #ifndef __IAIFilePath__
00018 #define __IAIFilePath__
00019 
00020 #include "IAIUnicodeString.h"
00021 
00022 /*HACK for int32_t and uint32_t redefinition error in VS2012: In case of VS2012 compiler, "memory" file includes stdint.h which, 
00023                 for some reason, points to dvacore/sys/win/stdint.h. As a result, datatypes defined in stdint.h throw redefinition errors.      */
00024 #if defined(_MSC_VER) && _MSC_VER >= 1700
00025 #define _ADOBE_STDINT_H_
00026 #endif
00027 
00028 #include <memory>
00029 
00030 #if defined(_MSC_VER) && _MSC_VER >= 1700
00031 #undef _ADOBE_STDINT_H_
00032 #endif
00033 
00034 
00035 #ifdef MAC_ENV
00036     #ifdef __OBJC__
00037         #import <Foundation/NSURL.h>
00038         #import <Foundation/NSString.h>
00039     #endif
00040     #ifndef __COREFOUNDATION_CFURL__
00041         #include <CoreFoundation/CFURL.h>
00042     #endif
00043     #if defined(IOS_ENV)
00044                 typedef short FSVolumeRefNum;
00045         #else
00046         #ifndef __FILES__
00047             #include <Carbon/Carbon.h>
00048         #endif
00049     #endif      // !defined(IOS_ENV)
00050 #else
00051 
00052 typedef signed long OSStatus;
00053 #endif
00054 
00055 struct FSSpec;
00056 struct MiFile;
00057 
00058 namespace ai {
00059 
00060 #ifdef WIN_ENV
00061 const ai::uint32 MaxPath = 259;
00062 #endif
00063 #ifdef MAC_ENV
00064 const ai::uint32 MaxPath = 1023;
00065 #endif
00066 const ai::uint32 MaxFile = 255;
00067 
00068 class FilePath
00069 {
00070         public:
00071 
00072         /* Some file system operations can be very slow. For example, on Windows,
00073                 UNC path names are used to access files on remote volumes. Determining
00074                 the availability of those remote volumes can require significant time
00075                 especially in the presence of the Windows client for NFS. For this
00076                 reason volume availability information is cached. */
00077 
00082         static void ResetVolumeCache() AINOTHROW;
00083 
00085         FilePath() AINOTHROW;
00087         FilePath(const FilePath&);
00088 
00097         explicit FilePath(const ai::UnicodeString &path, bool expandName = true);
00098 
00107         explicit FilePath(const MiFile&);
00108 
00109 
00110         
00111         explicit FilePath(const SPPlatformFileReference&);
00112 
00113         #ifdef MAC_ENV
00114 
00118         explicit FilePath(const CFStringRef);
00119 
00124 #if DEPRICATED_IN_10_8
00125         explicit FilePath(const FSRef&);
00126 #endif
00127 
00132         explicit FilePath(const CFURLRef);
00133     
00134     #ifdef __OBJC__
00135 
00138     explicit FilePath( NSData* inBookmarkData, const FilePath& inRelativeToPath = FilePath() );
00139     #endif //__OBJC__
00140     
00141         #endif  // MAC_ENV
00142 
00144         ~FilePath();
00145 
00147         FilePath &operator=(const FilePath&);
00148 
00152         bool IsEmpty() const;
00153 
00157         void MakeEmpty();
00158 
00167         bool Equal(const FilePath& filePath, const bool resolveLinks = false) const;
00169         bool operator==(const FilePath&) const;
00171         bool operator!=(const FilePath&) const;
00172 
00174         bool operator<(const FilePath&) const;
00175 
00180         bool StartsWithDelimiter() const;
00181 
00186         bool EndsWithDelimiter() const;
00187 
00195         void AddComponent(const ai::UnicodeString &addend = ai::UnicodeString());
00203         void AddComponent(const FilePath &addend);
00204 
00208         void RemoveComponent();
00209 
00215         void AddExtension(const ai::UnicodeString &ext);
00221         void AddExtension(const std::string &ext);
00225         void RemoveExtension();
00226 
00238         bool Exists(const bool resolveLinks,
00239                                 ai::UnicodeString *longPath = 0, bool *isFile = 0) const;
00240 
00246         void Resolve();
00247 
00248         /*****************************************************************************/
00249         /* Set operations */
00250 
00259         void Set(const ai::UnicodeString &path, bool expandName = true);
00260 
00264         void SetFromMiFile(const MiFile&);
00265 
00266         void SetFromSPFileRef(const SPPlatformFileReference&);
00267 
00268         #ifdef MAC_ENV
00269 
00273         void SetFromCFString(const CFStringRef);
00274 
00278 #if DEPRICATED_IN_10_8
00279         OSStatus SetFromFSRef(const FSRef&);
00280 #endif
00281 
00285         void SetFromCFURL(const CFURLRef);
00286     
00287     #ifdef __OBJC__
00288 
00291     BOOL SetFromBookmarkData( NSData* inBookmarkData, const FilePath& inRelativeToPath = FilePath(), NSError** inError = NULL );
00292     #endif //__OBJC__
00293         
00294     #endif      // MAC_ENV
00295 
00296 
00297         /*****************************************************************************/
00298         /* Get operations */
00299 
00304         ai::UnicodeString GetFileName(const bool displayName = false) const;
00305 
00309         ai::UnicodeString GetFileNameNoExt() const;
00310 
00315         ai::UnicodeString GetFileExtension() const;
00316 
00321         ai::UnicodeString GetFullPath(const bool displayName = false) const;
00322 
00329         ai::UnicodeString GetDirectory(const bool displayName = false) const;
00330 
00338         ai::UnicodeString GetShortPath() const;
00339 
00348         FilePath GetParent() const;
00349 
00351         //On hold due to lack of demand
00352         //FilePath GetRelativePath(const FilePath &base) const;
00353 
00355         //On hold due to lack of demand
00356         //FilePath GetAbsolutePath(const FilePath &base) const;
00357 
00361         static const char GetDelimiter() AINOTHROW;
00362 
00363         #ifdef MAC_ENV
00364     
00365     #if DEPRICATED_IN_10_8
00366 
00373     void GetVolumeAndParent(FSVolumeRefNum *vol, UInt32 *parent) const;
00374     #endif
00375     
00376     #ifdef __OBJC__
00377 
00384         void GetVolumeAndParent(NSURL **volume, NSURL **parent) const;
00385     #endif
00386     #endif
00387 
00394         AIErr GetCreatorAndType(ai::uint32 *creator, ai::uint32 *type) const;
00395 
00402         ai::UnicodeString GetAsURL(const bool displayName) const;
00403 
00404         void GetAsSPPlatformFileRef(SPPlatformFileReference&) const;
00405 
00407         AIErr GetAsMiFile(MiFile&) const;
00408 
00410         AIErr GetAsMiFile(MiFile*&) const;
00411 
00412         #ifdef MAC_ENV
00413 
00417         CFStringRef GetAsCFString() const;
00418 
00423 #if DEPRICATED_IN_10_8
00424         OSStatus GetAsFSRef(FSRef& result) const;
00425 #endif
00426 
00430         CFURLRef GetAsCFURL() const;
00431 
00432     #ifdef __OBJC__
00433     NSString* GetAsNSString         () const;
00434     
00435     NSURL*  GetAsNSURL              () const;
00436     
00437     NSData* GetAsBookmarkData       (  const FilePath& inRelativeToPath = FilePath(), NSError** inError = NULL ) const;
00438     
00439     NSData* GetAsMinimalBookmarkData(  const FilePath& inRelativeToPath = FilePath(), NSError** inError = NULL ) const;
00440     
00441     BOOL    IsAlias                 () const;
00442     
00443     BOOL    IsOnNetwork             () const;
00444     
00445     BOOL    IsEjectable             () const;
00446     #endif
00447         
00448 #endif  // MAC_ENV
00449 
00450         private:
00451         class FilePathImpl *impl;
00452 };
00453 
00454 } // namespace ai
00455 
00457 // Inline members
00458 //
00459 
00461 inline void ai::FilePath::AddComponent(const FilePath &addend)
00462 {
00463         AddComponent(addend.GetFullPath());
00464 }
00465 
00467 inline void ai::FilePath::AddExtension(const std::string &ext)
00468 {
00469         AddExtension(ai::UnicodeString(ext));
00470 }
00471 
00472 
00473 #endif // __IAIFilePath__


Contents Suites Classes Class Index Member Index
Adobe Solutions Network
 
Copyright © 2016 Adobe Systems Incorporated. All rights reserved.
Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks