FileSystemUtils.h (1524B)
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 file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_FileSystemUtils_h 8 #define mozilla_dom_FileSystemUtils_h 9 10 #include "nsIGlobalObject.h" 11 #include "nsStringFwd.h" 12 #include "nsTArray.h" 13 14 class nsIFile; 15 class nsIRunnable; 16 17 namespace mozilla::dom { 18 19 #define FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL "/" 20 #define FILESYSTEM_DOM_PATH_SEPARATOR_CHAR '/' 21 22 /* 23 * This class is for error handling. 24 * All methods in this class are static. 25 */ 26 class FileSystemUtils { 27 public: 28 /* 29 * Return true if aDescendantPath is a descendant of aPath. 30 */ 31 static bool IsDescendantPath(const nsAString& aPath, 32 const nsAString& aDescendantPath); 33 34 /** 35 * Return true if this is valid DOMPath. It also splits the path in 36 * subdirectories and stores them in aParts. 37 */ 38 static bool IsValidRelativeDOMPath(const nsAString& aPath, 39 nsTArray<nsString>& aParts); 40 41 /** 42 * Helper method. If aGlobal is null, the SystemGroup EventTarget will be 43 * used. 44 */ 45 static nsresult DispatchRunnable(nsIGlobalObject* aGlobal, 46 already_AddRefed<nsIRunnable>&& aRunnable); 47 }; 48 49 } // namespace mozilla::dom 50 51 #endif // mozilla_dom_FileSystemUtils_h