xpcom/io/nsLocalFileWin.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/io/nsLocalFileWin.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,110 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef _nsLocalFileWIN_H_
    1.10 +#define _nsLocalFileWIN_H_
    1.11 +
    1.12 +#include "nscore.h"
    1.13 +#include "nsError.h"
    1.14 +#include "nsString.h"
    1.15 +#include "nsCRT.h"
    1.16 +#include "nsIFile.h"
    1.17 +#include "nsIFactory.h"
    1.18 +#include "nsILocalFileWin.h"
    1.19 +#include "nsIHashable.h"
    1.20 +#include "nsIClassInfoImpl.h"
    1.21 +#include "prio.h"
    1.22 +
    1.23 +#include "mozilla/Attributes.h"
    1.24 +
    1.25 +#include "windows.h"
    1.26 +#include "shlobj.h"
    1.27 +
    1.28 +#include <sys/stat.h>
    1.29 +
    1.30 +class nsLocalFile MOZ_FINAL : public nsILocalFileWin,
    1.31 +                              public nsIHashable
    1.32 +{
    1.33 +public:
    1.34 +    NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
    1.35 +    
    1.36 +    nsLocalFile();
    1.37 +
    1.38 +    static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
    1.39 +
    1.40 +    // nsISupports interface
    1.41 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.42 +    
    1.43 +    // nsIFile interface
    1.44 +    NS_DECL_NSIFILE
    1.45 +    
    1.46 +    // nsILocalFile interface
    1.47 +    NS_DECL_NSILOCALFILE
    1.48 +
    1.49 +    // nsILocalFileWin interface
    1.50 +    NS_DECL_NSILOCALFILEWIN
    1.51 +
    1.52 +    // nsIHashable interface
    1.53 +    NS_DECL_NSIHASHABLE
    1.54 +
    1.55 +public:
    1.56 +    static void GlobalInit();
    1.57 +    static void GlobalShutdown();
    1.58 +
    1.59 +private:
    1.60 +    // CopyMove and CopySingleFile constants for |options| parameter:
    1.61 +    enum CopyFileOption {
    1.62 +      FollowSymlinks          = 1u << 0,
    1.63 +      Move                    = 1u << 1,
    1.64 +      SkipNtfsAclReset        = 1u << 2,
    1.65 +      Rename                  = 1u << 3
    1.66 +    };
    1.67 +
    1.68 +    nsLocalFile(const nsLocalFile& other);
    1.69 +    ~nsLocalFile() {}
    1.70 +
    1.71 +    bool mDirty;            // cached information can only be used when this is false
    1.72 +    bool mResolveDirty;
    1.73 +    bool mFollowSymlinks;   // should we follow symlinks when working on this file
    1.74 +    
    1.75 +    // this string will always be in native format!
    1.76 +    nsString mWorkingPath;
    1.77 +    
    1.78 +    // this will be the resolved path of shortcuts, it will *NEVER* 
    1.79 +    // be returned to the user
    1.80 +    nsString mResolvedPath;
    1.81 +
    1.82 +    // this string, if not empty, is the *short* pathname that represents
    1.83 +    // mWorkingPath
    1.84 +    nsString mShortWorkingPath;
    1.85 +
    1.86 +    PRFileInfo64 mFileInfo64;
    1.87 +
    1.88 +    void MakeDirty() 
    1.89 +    { 
    1.90 +      mDirty = true;
    1.91 +      mResolveDirty = true;
    1.92 +      mShortWorkingPath.Truncate();
    1.93 +    }
    1.94 +
    1.95 +    nsresult ResolveAndStat();
    1.96 +    nsresult Resolve();
    1.97 +    nsresult ResolveShortcut();
    1.98 +
    1.99 +    void EnsureShortPath();
   1.100 +    
   1.101 +    nsresult CopyMove(nsIFile *newParentDir, const nsAString &newName,
   1.102 +                      uint32_t options);
   1.103 +    nsresult CopySingleFile(nsIFile *source, nsIFile* dest,
   1.104 +                            const nsAString &newName,
   1.105 +                            uint32_t options);
   1.106 +
   1.107 +    nsresult SetModDate(int64_t aLastModifiedTime, const wchar_t *filePath);
   1.108 +    nsresult HasFileAttribute(DWORD fileAttrib, bool *_retval);
   1.109 +    nsresult AppendInternal(const nsAFlatString &node,
   1.110 +                            bool multipleComponents);
   1.111 +};
   1.112 +
   1.113 +#endif

mercurial