2014-03-05 07:26:39 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_Directory_h
|
|
|
|
#define mozilla_dom_Directory_h
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-07-19 05:31:11 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2014-03-05 07:26:39 +04:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-03-12 10:30:21 +04:00
|
|
|
#include "nsDOMFile.h"
|
2014-03-05 07:26:39 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
|
|
|
// Resolve the name collision of Microsoft's API name with macros defined in
|
|
|
|
// Windows header files. Undefine the macro of CreateDirectory to avoid
|
|
|
|
// Directory#CreateDirectory being replaced by Directory#CreateDirectoryW.
|
|
|
|
#ifdef CreateDirectory
|
|
|
|
#undef CreateDirectory
|
|
|
|
#endif
|
2014-03-05 12:40:48 +04:00
|
|
|
// Undefine the macro of CreateFile to avoid Directory#CreateFile being replaced
|
|
|
|
// by Directory#CreateFileW.
|
|
|
|
#ifdef CreateFile
|
|
|
|
#undef CreateFile
|
|
|
|
#endif
|
2014-03-05 07:26:39 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-06-19 04:57:51 +04:00
|
|
|
struct CreateFileOptions;
|
2014-03-05 07:25:40 +04:00
|
|
|
class FileSystemBase;
|
2014-03-05 07:26:39 +04:00
|
|
|
class Promise;
|
2014-03-12 10:30:21 +04:00
|
|
|
class StringOrFileOrDirectory;
|
2014-03-05 07:26:39 +04:00
|
|
|
|
|
|
|
class Directory MOZ_FINAL
|
|
|
|
: public nsISupports
|
|
|
|
, public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory)
|
|
|
|
|
|
|
|
public:
|
2014-03-05 07:25:40 +04:00
|
|
|
static already_AddRefed<Promise>
|
2014-07-19 05:31:11 +04:00
|
|
|
GetRoot(FileSystemBase* aFileSystem, ErrorResult& aRv);
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
Directory(FileSystemBase* aFileSystem, const nsAString& aPath);
|
2014-03-05 07:26:39 +04:00
|
|
|
|
|
|
|
// ========= Begin WebIDL bindings. ===========
|
|
|
|
|
|
|
|
nsPIDOMWindow*
|
|
|
|
GetParentObject() const;
|
|
|
|
|
|
|
|
virtual JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2014-03-05 07:26:39 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
GetName(nsString& aRetval) const;
|
|
|
|
|
2014-03-05 12:40:48 +04:00
|
|
|
already_AddRefed<Promise>
|
2014-07-19 05:31:11 +04:00
|
|
|
CreateFile(const nsAString& aPath, const CreateFileOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
2014-03-05 12:40:48 +04:00
|
|
|
|
2014-03-05 07:26:39 +04:00
|
|
|
already_AddRefed<Promise>
|
2014-07-19 05:31:11 +04:00
|
|
|
CreateDirectory(const nsAString& aPath, ErrorResult& aRv);
|
2014-03-05 07:26:39 +04:00
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2014-07-19 05:31:11 +04:00
|
|
|
Get(const nsAString& aPath, ErrorResult& aRv);
|
2014-03-05 07:26:39 +04:00
|
|
|
|
2014-03-12 10:30:21 +04:00
|
|
|
already_AddRefed<Promise>
|
2014-07-19 05:31:11 +04:00
|
|
|
Remove(const StringOrFileOrDirectory& aPath, ErrorResult& aRv);
|
2014-03-12 10:30:21 +04:00
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2014-07-19 05:31:11 +04:00
|
|
|
RemoveDeep(const StringOrFileOrDirectory& aPath, ErrorResult& aRv);
|
2014-03-12 10:30:21 +04:00
|
|
|
|
2014-03-05 07:26:39 +04:00
|
|
|
// =========== End WebIDL bindings.============
|
2014-03-12 10:30:21 +04:00
|
|
|
|
|
|
|
FileSystemBase*
|
|
|
|
GetFileSystem() const;
|
2014-03-05 07:25:40 +04:00
|
|
|
private:
|
2014-06-23 23:56:07 +04:00
|
|
|
~Directory();
|
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
static bool
|
|
|
|
IsValidRelativePath(const nsString& aPath);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert relative DOM path to the absolute real path.
|
|
|
|
* @return true if succeed. false if the DOM path is invalid.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
DOMPathToRealPath(const nsAString& aPath, nsAString& aRealPath) const;
|
|
|
|
|
2014-03-12 10:30:21 +04:00
|
|
|
already_AddRefed<Promise>
|
2014-07-19 05:31:11 +04:00
|
|
|
RemoveInternal(const StringOrFileOrDirectory& aPath, bool aRecursive,
|
|
|
|
ErrorResult& aRv);
|
2014-03-12 10:30:21 +04:00
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
nsRefPtr<FileSystemBase> mFileSystem;
|
|
|
|
nsString mPath;
|
2014-03-05 07:26:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_Directory_h
|