mirror of
https://github.com/par274/sharpemu.git
synced 2026-08-03 08:29:53 +08:00
38 lines
775 B
C#
38 lines
775 B
C#
// Copyright (C) 2026 SharpEmu Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
namespace SharpEmu.Core;
|
|
|
|
public sealed class PhysicalFileSystem : IFileSystem
|
|
{
|
|
public bool Exists(string path)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
return false;
|
|
|
|
return File.Exists(path);
|
|
}
|
|
|
|
public bool TryReadAllBytes(string path, out byte[] data)
|
|
{
|
|
data = Array.Empty<byte>();
|
|
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
return false;
|
|
|
|
if (!File.Exists(path))
|
|
return false;
|
|
|
|
try
|
|
{
|
|
data = File.ReadAllBytes(path);
|
|
return true;
|
|
}
|
|
catch
|
|
{
|
|
data = Array.Empty<byte>();
|
|
return false;
|
|
}
|
|
}
|
|
}
|