Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef _nsLocalFileWIN_H_ |
michael@0 | 7 | #define _nsLocalFileWIN_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nscore.h" |
michael@0 | 10 | #include "nsError.h" |
michael@0 | 11 | #include "nsString.h" |
michael@0 | 12 | #include "nsCRT.h" |
michael@0 | 13 | #include "nsIFile.h" |
michael@0 | 14 | #include "nsIFactory.h" |
michael@0 | 15 | #include "nsILocalFileWin.h" |
michael@0 | 16 | #include "nsIHashable.h" |
michael@0 | 17 | #include "nsIClassInfoImpl.h" |
michael@0 | 18 | #include "prio.h" |
michael@0 | 19 | |
michael@0 | 20 | #include "mozilla/Attributes.h" |
michael@0 | 21 | |
michael@0 | 22 | #include "windows.h" |
michael@0 | 23 | #include "shlobj.h" |
michael@0 | 24 | |
michael@0 | 25 | #include <sys/stat.h> |
michael@0 | 26 | |
michael@0 | 27 | class nsLocalFile MOZ_FINAL : public nsILocalFileWin, |
michael@0 | 28 | public nsIHashable |
michael@0 | 29 | { |
michael@0 | 30 | public: |
michael@0 | 31 | NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID) |
michael@0 | 32 | |
michael@0 | 33 | nsLocalFile(); |
michael@0 | 34 | |
michael@0 | 35 | static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); |
michael@0 | 36 | |
michael@0 | 37 | // nsISupports interface |
michael@0 | 38 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 39 | |
michael@0 | 40 | // nsIFile interface |
michael@0 | 41 | NS_DECL_NSIFILE |
michael@0 | 42 | |
michael@0 | 43 | // nsILocalFile interface |
michael@0 | 44 | NS_DECL_NSILOCALFILE |
michael@0 | 45 | |
michael@0 | 46 | // nsILocalFileWin interface |
michael@0 | 47 | NS_DECL_NSILOCALFILEWIN |
michael@0 | 48 | |
michael@0 | 49 | // nsIHashable interface |
michael@0 | 50 | NS_DECL_NSIHASHABLE |
michael@0 | 51 | |
michael@0 | 52 | public: |
michael@0 | 53 | static void GlobalInit(); |
michael@0 | 54 | static void GlobalShutdown(); |
michael@0 | 55 | |
michael@0 | 56 | private: |
michael@0 | 57 | // CopyMove and CopySingleFile constants for |options| parameter: |
michael@0 | 58 | enum CopyFileOption { |
michael@0 | 59 | FollowSymlinks = 1u << 0, |
michael@0 | 60 | Move = 1u << 1, |
michael@0 | 61 | SkipNtfsAclReset = 1u << 2, |
michael@0 | 62 | Rename = 1u << 3 |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | nsLocalFile(const nsLocalFile& other); |
michael@0 | 66 | ~nsLocalFile() {} |
michael@0 | 67 | |
michael@0 | 68 | bool mDirty; // cached information can only be used when this is false |
michael@0 | 69 | bool mResolveDirty; |
michael@0 | 70 | bool mFollowSymlinks; // should we follow symlinks when working on this file |
michael@0 | 71 | |
michael@0 | 72 | // this string will always be in native format! |
michael@0 | 73 | nsString mWorkingPath; |
michael@0 | 74 | |
michael@0 | 75 | // this will be the resolved path of shortcuts, it will *NEVER* |
michael@0 | 76 | // be returned to the user |
michael@0 | 77 | nsString mResolvedPath; |
michael@0 | 78 | |
michael@0 | 79 | // this string, if not empty, is the *short* pathname that represents |
michael@0 | 80 | // mWorkingPath |
michael@0 | 81 | nsString mShortWorkingPath; |
michael@0 | 82 | |
michael@0 | 83 | PRFileInfo64 mFileInfo64; |
michael@0 | 84 | |
michael@0 | 85 | void MakeDirty() |
michael@0 | 86 | { |
michael@0 | 87 | mDirty = true; |
michael@0 | 88 | mResolveDirty = true; |
michael@0 | 89 | mShortWorkingPath.Truncate(); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | nsresult ResolveAndStat(); |
michael@0 | 93 | nsresult Resolve(); |
michael@0 | 94 | nsresult ResolveShortcut(); |
michael@0 | 95 | |
michael@0 | 96 | void EnsureShortPath(); |
michael@0 | 97 | |
michael@0 | 98 | nsresult CopyMove(nsIFile *newParentDir, const nsAString &newName, |
michael@0 | 99 | uint32_t options); |
michael@0 | 100 | nsresult CopySingleFile(nsIFile *source, nsIFile* dest, |
michael@0 | 101 | const nsAString &newName, |
michael@0 | 102 | uint32_t options); |
michael@0 | 103 | |
michael@0 | 104 | nsresult SetModDate(int64_t aLastModifiedTime, const wchar_t *filePath); |
michael@0 | 105 | nsresult HasFileAttribute(DWORD fileAttrib, bool *_retval); |
michael@0 | 106 | nsresult AppendInternal(const nsAFlatString &node, |
michael@0 | 107 | bool multipleComponents); |
michael@0 | 108 | }; |
michael@0 | 109 | |
michael@0 | 110 | #endif |