LCOV - code coverage report
Current view: top level - source/lib/file/common - real_directory.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 14 20 70.0 %
Date: 2026-12-03 01:19:39 Functions: 5 7 71.4 %

          Line data    Source code
       1             : /* Copyright (C) 2026 Wildfire Games.
       2             :  *
       3             :  * Permission is hereby granted, free of charge, to any person obtaining
       4             :  * a copy of this software and associated documentation files (the
       5             :  * "Software"), to deal in the Software without restriction, including
       6             :  * without limitation the rights to use, copy, modify, merge, publish,
       7             :  * distribute, sublicense, and/or sell copies of the Software, and to
       8             :  * permit persons to whom the Software is furnished to do so, subject to
       9             :  * the following conditions:
      10             :  *
      11             :  * The above copyright notice and this permission notice shall be included
      12             :  * in all copies or substantial portions of the Software.
      13             :  *
      14             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      15             :  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      16             :  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      17             :  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
      18             :  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
      19             :  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      20             :  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      21             :  */
      22             : 
      23             : #include "precompiled.h"
      24             : 
      25             : #include "real_directory.h"
      26             : 
      27             : #include "lib/debug.h"
      28             : #include "lib/file/io/io.h"
      29             : #include "lib/path.h"
      30             : 
      31             : 
      32        1924 : RealDirectory::RealDirectory(const OsPath& path, size_t priority, size_t flags)
      33        3848 :     : m_path(path), m_priority(priority), m_flags(flags)
      34             : {
      35        1924 :     ENSURE(path.IsDirectory());
      36        1924 : }
      37             : 
      38             : 
      39         250 : /*virtual*/ size_t RealDirectory::Precedence() const
      40             : {
      41         250 :     return 1u;
      42             : }
      43             : 
      44             : 
      45           0 : /*virtual*/ wchar_t RealDirectory::LocationCode() const
      46             : {
      47           0 :     return 'F';
      48             : }
      49             : 
      50             : 
      51       14088 : /*virtual*/ Status RealDirectory::Load(const OsPath& name, const std::span<std::uint8_t> buffer) const
      52             : {
      53       42264 :     return io::Load(m_path / name, buffer.data(), buffer.size());
      54             : }
      55             : 
      56             : 
      57        2108 : Status RealDirectory::Store(const OsPath& name, std::span<const std::uint8_t> fileContents)
      58             : {
      59        6324 :     return io::Store(m_path / name, fileContents.data(), fileContents.size());
      60             : }
      61             : 
      62             : 
      63           0 : void RealDirectory::Watch()
      64             : {
      65           0 :     if(!m_watch)
      66           0 :         (void)dir_watch_Add(m_path, m_watch);
      67           0 : }
      68             : 
      69             : 
      70        1425 : PRealDirectory CreateRealSubdirectory(const PRealDirectory& realDirectory, const OsPath& subdirectoryName)
      71             : {
      72        2850 :     const OsPath path = realDirectory->Path() / subdirectoryName/"";
      73        2850 :     return PRealDirectory(new RealDirectory(path, realDirectory->Priority(), realDirectory->Flags()));
      74        1425 : }

Generated by: LCOV version 1.16