Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / xpcom / io / nsLocalFileWin.h
bloba3ea03a666cf710305c73ad83ac746be02034b86
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_
10 #include "nscore.h"
11 #include "nsError.h"
12 #include "nsString.h"
13 #include "nsCRT.h"
14 #include "nsIFile.h"
15 #include "nsILocalFileWin.h"
16 #include "nsIClassInfoImpl.h"
17 #include "prio.h"
19 #include "mozilla/Attributes.h"
21 #include <windows.h>
22 #include <shlobj.h>
24 #include <sys/stat.h>
26 class nsLocalFile final : public nsILocalFileWin {
27 public:
28 NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
30 nsLocalFile();
31 explicit nsLocalFile(const nsAString& aFilePath);
33 static nsresult nsLocalFileConstructor(const nsIID& aIID,
34 void** aInstancePtr);
36 // nsISupports interface
37 NS_DECL_THREADSAFE_ISUPPORTS
39 // nsIFile interface
40 NS_DECL_NSIFILE
42 // nsILocalFileWin interface
43 NS_DECL_NSILOCALFILEWIN
45 public:
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;
57 struct FileInfo {
58 PRFileType type;
59 PROffset64 size;
60 PRTime creationTime;
61 PRTime accessTime;
62 PRTime modifyTime;
65 private:
66 // CopyMove and CopySingleFile constants for |options| parameter:
67 enum CopyFileOption {
68 FollowSymlinks = 1u << 0,
69 Move = 1u << 1,
70 SkipNtfsAclReset = 1u << 2,
71 Rename = 1u << 3
74 nsLocalFile(const nsLocalFile& aOther);
75 ~nsLocalFile() {}
77 bool mDirty; // cached information can only be used when this is false
78 bool mResolveDirty;
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
90 // mWorkingPath
91 nsString mShortWorkingPath;
93 FileInfo mFileInfo;
95 void MakeDirty() {
96 mDirty = true;
97 mResolveDirty = true;
98 mShortWorkingPath.Truncate();
101 nsresult LookupExtensionIn(const char* const* aExtensionsArray,
102 size_t aArrayLength, bool* aResult);
104 nsresult ResolveAndStat();
105 nsresult Resolve();
106 nsresult ResolveSymlink();
108 void EnsureShortPath();
110 nsresult CopyMove(nsIFile* aNewParentDir, const nsAString& aNewName,
111 uint32_t aOptions);
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,
123 bool aShareDelete,
124 PRFileDesc** aResult);
127 #endif