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