1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef _nsLocalFileWIN_H_
8 #define _nsLocalFileWIN_H_
15 #include "nsILocalFileWin.h"
16 #include "nsIClassInfoImpl.h"
19 #include "mozilla/Attributes.h"
26 class nsLocalFile final
: public nsILocalFileWin
{
28 NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID
)
31 explicit nsLocalFile(const nsAString
& aFilePath
);
33 static nsresult
nsLocalFileConstructor(const nsIID
& aIID
,
36 // nsISupports interface
37 NS_DECL_THREADSAFE_ISUPPORTS
42 // nsILocalFileWin interface
43 NS_DECL_NSILOCALFILEWIN
46 // Removes registry command handler parameters, quotes, and expands
47 // environment strings.
48 static bool CleanupCmdHandlerPath(nsAString
& aCommandHandler
);
49 // Called off the main thread to open the window revealing the file
50 static nsresult
RevealFile(const nsString
& aResolvedPath
);
52 // Checks if the filename is one of the windows reserved filenames
53 // (com1, com2, etc...) and returns true if so.
54 static bool CheckForReservedFileName(const nsString
& aFileName
);
56 // PRFileInfo64 does not hvae an accessTime field;
66 // CopyMove and CopySingleFile constants for |options| parameter:
68 FollowSymlinks
= 1u << 0,
70 SkipNtfsAclReset
= 1u << 2,
74 nsLocalFile(const nsLocalFile
& aOther
);
77 bool mDirty
; // cached information can only be used when this is false
80 bool mUseDOSDevicePathSyntax
;
82 // this string will always be in native format!
83 nsString mWorkingPath
;
85 // this will be the resolved path of shortcuts, it will *NEVER*
86 // be returned to the user
87 nsString mResolvedPath
;
89 // this string, if not empty, is the *short* pathname that represents
91 nsString mShortWorkingPath
;
98 mShortWorkingPath
.Truncate();
101 nsresult
LookupExtensionIn(const char* const* aExtensionsArray
,
102 size_t aArrayLength
, bool* aResult
);
104 nsresult
ResolveAndStat();
106 nsresult
ResolveSymlink();
108 void EnsureShortPath();
110 nsresult
CopyMove(nsIFile
* aNewParentDir
, const nsAString
& aNewName
,
112 nsresult
CopySingleFile(nsIFile
* aSource
, nsIFile
* aDest
,
113 const nsAString
& aNewName
, uint32_t aOptions
);
115 enum class TimeField
{ AccessedTime
, ModifiedTime
};
117 nsresult
SetDateImpl(int64_t aTime
, TimeField aTimeField
);
118 nsresult
GetDateImpl(PRTime
* aTime
, TimeField aTimeField
, bool aFollowLinks
);
119 nsresult
HasFileAttribute(DWORD aFileAttrib
, bool* aResult
);
120 nsresult
AppendInternal(const nsString
& aNode
, bool aMultipleComponents
);
122 nsresult
OpenNSPRFileDescMaybeShareDelete(int32_t aFlags
, int32_t aMode
,
124 PRFileDesc
** aResult
);