tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

FileSystemParentTypes.h (1492B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef DOM_FS_PARENT_FILESYSTEMPARENTTYPES_H_
      8 #define DOM_FS_PARENT_FILESYSTEMPARENTTYPES_H_
      9 
     10 #include "nsStringFwd.h"
     11 #include "nsTString.h"
     12 
     13 namespace mozilla::dom::fs {
     14 
     15 /**
     16 * @brief FileId refers to a file on disk while EntryId refers to a path.
     17 * Same user input path will always generate the same EntryId while the FileId
     18 * can be different. Move methods can change the FileId which underlies
     19 * an EntryId and multiple FileIds for temporary files can all map to the same
     20 * EntryId.
     21 */
     22 struct FileId {
     23  explicit FileId(const nsCString& aValue) : mValue(aValue) {}
     24 
     25  explicit FileId(nsCString&& aValue) : mValue(std::move(aValue)) {}
     26 
     27  constexpr bool IsEmpty() const { return mValue.IsEmpty(); }
     28 
     29  constexpr const nsCString& Value() const { return mValue; }
     30 
     31  nsCString mValue;
     32 };
     33 
     34 inline bool operator==(const FileId& aLhs, const FileId& aRhs) {
     35  return aLhs.mValue == aRhs.mValue;
     36 }
     37 
     38 inline bool operator!=(const FileId& aLhs, const FileId& aRhs) {
     39  return aLhs.mValue != aRhs.mValue;
     40 }
     41 
     42 enum class FileMode { EXCLUSIVE, SHARED_FROM_EMPTY, SHARED_FROM_COPY };
     43 
     44 }  // namespace mozilla::dom::fs
     45 
     46 #endif  // DOM_FS_PARENT_FILESYSTEMPARENTTYPES_H_