mirror of
https://github.com/holub/mame
synced 2025-05-22 05:38:52 +03:00

* Sync with bgfx upstream revision b91d0b6 * Sync with bx upstream revision d60912b * Sync with bimg upstream revision bd81f60 * Add astc-codec decoder * Rename VertexDecl to VertexLayout * Rename UniformType enum Int1 to Sampler. * Add NVN stub * Fix unused-const-variable error on macOS * Drop redundant explicit language parameters buildoptions_cpp are only applied to c++ files and buildoptions_objcpp are only applied to objective c++ files. As such, hardcoding -x offers no benefit while preventing overrides (such as one needed by 3rdparty/bgfx/src/renderer_vk.cpp on macOS) from working. * Re-introduce -x c++ in places where C code is compiled as C++ to prevent clang from throwing a warning * Build bgfx as Objective-C++ on macOS It is needed due to included headers * Enable Direct3D12 and Vulkan bgfx rendering backends * Enable building of spirv shaders * Properly escape /c in cmd call * Comment out dx12 bgfx renderer * Honor VERBOSE setting during shaders build * Only invert hlsl shader XYZ_TO_sRGB matrix for opengl * Add spirv shaders * OpenGL ES needs transposed matrix too * Metal needs transposed matrix as well
144 lines
2.8 KiB
C++
144 lines
2.8 KiB
C++
/*
|
|
* Copyright 2010-2019 Branimir Karadzic. All rights reserved.
|
|
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
|
|
*/
|
|
|
|
#ifndef BX_FILE_H_HEADER_GUARD
|
|
#define BX_FILE_H_HEADER_GUARD
|
|
|
|
#include "filepath.h"
|
|
#include "readerwriter.h"
|
|
|
|
namespace bx
|
|
{
|
|
/// Returns standard input reader.
|
|
ReaderI* getStdIn();
|
|
|
|
/// Returns standard output writer.
|
|
WriterI* getStdOut();
|
|
|
|
/// Returns standard error writer.
|
|
WriterI* getStdErr();
|
|
|
|
/// Returns null output writer.
|
|
WriterI* getNullOut();
|
|
|
|
/// File reader.
|
|
class FileReader : public FileReaderI
|
|
{
|
|
public:
|
|
///
|
|
FileReader();
|
|
|
|
///
|
|
virtual ~FileReader();
|
|
|
|
///
|
|
virtual bool open(const FilePath& _filePath, Error* _err) override;
|
|
|
|
///
|
|
virtual void close() override;
|
|
|
|
///
|
|
virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) override;
|
|
|
|
///
|
|
virtual int32_t read(void* _data, int32_t _size, Error* _err) override;
|
|
|
|
private:
|
|
BX_ALIGN_DECL(16, uint8_t) m_internal[64];
|
|
};
|
|
|
|
/// File writer.
|
|
class FileWriter : public FileWriterI
|
|
{
|
|
public:
|
|
///
|
|
FileWriter();
|
|
|
|
///
|
|
virtual ~FileWriter();
|
|
|
|
///
|
|
virtual bool open(const FilePath& _filePath, bool _append, Error* _err) override;
|
|
|
|
///
|
|
virtual void close() override;
|
|
|
|
///
|
|
virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) override;
|
|
|
|
///
|
|
virtual int32_t write(const void* _data, int32_t _size, Error* _err) override;
|
|
|
|
private:
|
|
BX_ALIGN_DECL(16, uint8_t) m_internal[64];
|
|
};
|
|
|
|
/// File type.
|
|
struct FileType
|
|
{
|
|
/// File types:
|
|
enum Enum
|
|
{
|
|
File, //!< File.
|
|
Dir, //!< Directory.
|
|
|
|
Count
|
|
};
|
|
};
|
|
|
|
/// File info.
|
|
struct FileInfo
|
|
{
|
|
FilePath filePath; //!< File path.
|
|
uint64_t size; //!< File size.
|
|
FileType::Enum type; //!< File type.
|
|
};
|
|
|
|
/// Directory reader.
|
|
class DirectoryReader : public ReaderOpenI, public CloserI, public ReaderI
|
|
{
|
|
public:
|
|
///
|
|
DirectoryReader();
|
|
|
|
///
|
|
virtual ~DirectoryReader();
|
|
|
|
///
|
|
virtual bool open(const FilePath& _filePath, Error* _err) override;
|
|
|
|
///
|
|
virtual void close() override;
|
|
|
|
///
|
|
virtual int32_t read(void* _data, int32_t _size, Error* _err) override;
|
|
|
|
private:
|
|
BX_ALIGN_DECL(16, uint8_t) m_internal[sizeof(FilePath)+sizeof(FileInfo)+16];
|
|
};
|
|
|
|
/// FIle stat.
|
|
bool stat(FileInfo& _outFileInfo, const FilePath& _filePath);
|
|
|
|
/// Creates a directory named `_filePath`.
|
|
///
|
|
bool make(const FilePath& _filePath, Error* _err = NULL);
|
|
|
|
/// Creates a directory named `_filePath` along with all necessary parents.
|
|
///
|
|
bool makeAll(const FilePath& _filePath, Error* _err = NULL);
|
|
|
|
/// Removes file or directory.
|
|
///
|
|
bool remove(const FilePath& _filePath, Error* _err = NULL);
|
|
|
|
/// Removes file or directory recursivelly.
|
|
///
|
|
bool removeAll(const FilePath& _filePath, Error* _err = NULL);
|
|
|
|
} // namespace bx
|
|
|
|
#endif // BX_FILE_H_HEADER_GUARD
|