dom/filesystem/Directory.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/filesystem/Directory.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,104 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_Directory_h
    1.11 +#define mozilla_dom_Directory_h
    1.12 +
    1.13 +#include "mozilla/Attributes.h"
    1.14 +#include "mozilla/dom/BindingDeclarations.h"
    1.15 +#include "nsAutoPtr.h"
    1.16 +#include "nsCycleCollectionParticipant.h"
    1.17 +#include "nsDOMFile.h"
    1.18 +#include "nsPIDOMWindow.h"
    1.19 +#include "nsWrapperCache.h"
    1.20 +
    1.21 +// Resolve the name collision of Microsoft's API name with macros defined in
    1.22 +// Windows header files. Undefine the macro of CreateDirectory to avoid
    1.23 +// Directory#CreateDirectory being replaced by Directory#CreateDirectoryW.
    1.24 +#ifdef CreateDirectory
    1.25 +#undef CreateDirectory
    1.26 +#endif
    1.27 +// Undefine the macro of CreateFile to avoid Directory#CreateFile being replaced
    1.28 +// by Directory#CreateFileW.
    1.29 +#ifdef CreateFile
    1.30 +#undef CreateFile
    1.31 +#endif
    1.32 +
    1.33 +namespace mozilla {
    1.34 +namespace dom {
    1.35 +
    1.36 +class CreateFileOptions;
    1.37 +class FileSystemBase;
    1.38 +class Promise;
    1.39 +class StringOrFileOrDirectory;
    1.40 +
    1.41 +class Directory MOZ_FINAL
    1.42 +  : public nsISupports
    1.43 +  , public nsWrapperCache
    1.44 +{
    1.45 +public:
    1.46 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.47 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory)
    1.48 +
    1.49 +public:
    1.50 +  static already_AddRefed<Promise>
    1.51 +  GetRoot(FileSystemBase* aFileSystem);
    1.52 +
    1.53 +  Directory(FileSystemBase* aFileSystem, const nsAString& aPath);
    1.54 +  ~Directory();
    1.55 +
    1.56 +  // ========= Begin WebIDL bindings. ===========
    1.57 +
    1.58 +  nsPIDOMWindow*
    1.59 +  GetParentObject() const;
    1.60 +
    1.61 +  virtual JSObject*
    1.62 +  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.63 +
    1.64 +  void
    1.65 +  GetName(nsString& aRetval) const;
    1.66 +
    1.67 +  already_AddRefed<Promise>
    1.68 +  CreateFile(const nsAString& aPath, const CreateFileOptions& aOptions);
    1.69 +
    1.70 +  already_AddRefed<Promise>
    1.71 +  CreateDirectory(const nsAString& aPath);
    1.72 +
    1.73 +  already_AddRefed<Promise>
    1.74 +  Get(const nsAString& aPath);
    1.75 +
    1.76 +  already_AddRefed<Promise>
    1.77 +  Remove(const StringOrFileOrDirectory& aPath);
    1.78 +
    1.79 +  already_AddRefed<Promise>
    1.80 +  RemoveDeep(const StringOrFileOrDirectory& aPath);
    1.81 +
    1.82 +  // =========== End WebIDL bindings.============
    1.83 +
    1.84 +  FileSystemBase*
    1.85 +  GetFileSystem() const;
    1.86 +private:
    1.87 +  static bool
    1.88 +  IsValidRelativePath(const nsString& aPath);
    1.89 +
    1.90 +  /*
    1.91 +   * Convert relative DOM path to the absolute real path.
    1.92 +   * @return true if succeed. false if the DOM path is invalid.
    1.93 +   */
    1.94 +  bool
    1.95 +  DOMPathToRealPath(const nsAString& aPath, nsAString& aRealPath) const;
    1.96 +
    1.97 +  already_AddRefed<Promise>
    1.98 +  RemoveInternal(const StringOrFileOrDirectory& aPath, bool aRecursive);
    1.99 +
   1.100 +  nsRefPtr<FileSystemBase> mFileSystem;
   1.101 +  nsString mPath;
   1.102 +};
   1.103 +
   1.104 +} // namespace dom
   1.105 +} // namespace mozilla
   1.106 +
   1.107 +#endif // mozilla_dom_Directory_h

mercurial