summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/fssrv/fssrv_sf_path.h
blob: a0c0b2dac8381051bed1bd5d17f08c9405938a60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "core/file_sys/fs_directory.h"

namespace FileSys::Sf {

struct Path {
    char str[EntryNameLengthMax + 1];

    static constexpr Path Encode(const char* p) {
        Path path = {};
        for (size_t i = 0; i < sizeof(path) - 1; i++) {
            path.str[i] = p[i];
            if (p[i] == '\x00') {
                break;
            }
        }
        return path;
    }

    static constexpr size_t GetPathLength(const Path& path) {
        size_t len = 0;
        for (size_t i = 0; i < sizeof(path) - 1 && path.str[i] != '\x00'; i++) {
            len++;
        }
        return len;
    }
};
static_assert(std::is_trivially_copyable_v<Path>, "Path must be trivially copyable.");

using FspPath = Path;

} // namespace FileSys::Sf