dom/filesystem/Directory.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_Directory_h
michael@0 8 #define mozilla_dom_Directory_h
michael@0 9
michael@0 10 #include "mozilla/Attributes.h"
michael@0 11 #include "mozilla/dom/BindingDeclarations.h"
michael@0 12 #include "nsAutoPtr.h"
michael@0 13 #include "nsCycleCollectionParticipant.h"
michael@0 14 #include "nsDOMFile.h"
michael@0 15 #include "nsPIDOMWindow.h"
michael@0 16 #include "nsWrapperCache.h"
michael@0 17
michael@0 18 // Resolve the name collision of Microsoft's API name with macros defined in
michael@0 19 // Windows header files. Undefine the macro of CreateDirectory to avoid
michael@0 20 // Directory#CreateDirectory being replaced by Directory#CreateDirectoryW.
michael@0 21 #ifdef CreateDirectory
michael@0 22 #undef CreateDirectory
michael@0 23 #endif
michael@0 24 // Undefine the macro of CreateFile to avoid Directory#CreateFile being replaced
michael@0 25 // by Directory#CreateFileW.
michael@0 26 #ifdef CreateFile
michael@0 27 #undef CreateFile
michael@0 28 #endif
michael@0 29
michael@0 30 namespace mozilla {
michael@0 31 namespace dom {
michael@0 32
michael@0 33 class CreateFileOptions;
michael@0 34 class FileSystemBase;
michael@0 35 class Promise;
michael@0 36 class StringOrFileOrDirectory;
michael@0 37
michael@0 38 class Directory MOZ_FINAL
michael@0 39 : public nsISupports
michael@0 40 , public nsWrapperCache
michael@0 41 {
michael@0 42 public:
michael@0 43 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 44 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory)
michael@0 45
michael@0 46 public:
michael@0 47 static already_AddRefed<Promise>
michael@0 48 GetRoot(FileSystemBase* aFileSystem);
michael@0 49
michael@0 50 Directory(FileSystemBase* aFileSystem, const nsAString& aPath);
michael@0 51 ~Directory();
michael@0 52
michael@0 53 // ========= Begin WebIDL bindings. ===========
michael@0 54
michael@0 55 nsPIDOMWindow*
michael@0 56 GetParentObject() const;
michael@0 57
michael@0 58 virtual JSObject*
michael@0 59 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 60
michael@0 61 void
michael@0 62 GetName(nsString& aRetval) const;
michael@0 63
michael@0 64 already_AddRefed<Promise>
michael@0 65 CreateFile(const nsAString& aPath, const CreateFileOptions& aOptions);
michael@0 66
michael@0 67 already_AddRefed<Promise>
michael@0 68 CreateDirectory(const nsAString& aPath);
michael@0 69
michael@0 70 already_AddRefed<Promise>
michael@0 71 Get(const nsAString& aPath);
michael@0 72
michael@0 73 already_AddRefed<Promise>
michael@0 74 Remove(const StringOrFileOrDirectory& aPath);
michael@0 75
michael@0 76 already_AddRefed<Promise>
michael@0 77 RemoveDeep(const StringOrFileOrDirectory& aPath);
michael@0 78
michael@0 79 // =========== End WebIDL bindings.============
michael@0 80
michael@0 81 FileSystemBase*
michael@0 82 GetFileSystem() const;
michael@0 83 private:
michael@0 84 static bool
michael@0 85 IsValidRelativePath(const nsString& aPath);
michael@0 86
michael@0 87 /*
michael@0 88 * Convert relative DOM path to the absolute real path.
michael@0 89 * @return true if succeed. false if the DOM path is invalid.
michael@0 90 */
michael@0 91 bool
michael@0 92 DOMPathToRealPath(const nsAString& aPath, nsAString& aRealPath) const;
michael@0 93
michael@0 94 already_AddRefed<Promise>
michael@0 95 RemoveInternal(const StringOrFileOrDirectory& aPath, bool aRecursive);
michael@0 96
michael@0 97 nsRefPtr<FileSystemBase> mFileSystem;
michael@0 98 nsString mPath;
michael@0 99 };
michael@0 100
michael@0 101 } // namespace dom
michael@0 102 } // namespace mozilla
michael@0 103
michael@0 104 #endif // mozilla_dom_Directory_h

mercurial