File File.h¶
File List > Amplitude > IO > File.h
Go to the documentation of this file
// Copyright (c) 2021-present Sparky Studios. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#ifndef _AM_IO_FILE_H
#define _AM_IO_FILE_H
#include <SparkyStudios/Audio/Amplitude/Core/Common.h>
namespace SparkyStudios::Audio::Amplitude
{
enum eFileOpenMode : AmUInt8
{
eFileOpenMode_Read = 0,
eFileOpenMode_Write = 1,
eFileOpenMode_Append = 2,
eFileOpenMode_ReadWrite = 3,
eFileOpenMode_ReadAppend = 4,
};
enum eFileOpenKind : AmUInt8
{
eFileOpenKind_Binary = 0,
eFileOpenKind_Text = 1,
};
enum eFileSeekOrigin : AmUInt8
{
eFileSeekOrigin_Start = SEEK_SET,
eFileSeekOrigin_Current = SEEK_CUR,
eFileSeekOrigin_End = SEEK_END,
};
class AM_API_PUBLIC File
{
public:
virtual ~File() = default;
[[nodiscard]] virtual AmOsString GetPath() const = 0;
[[nodiscard]] AmUInt8 Read8() const;
[[nodiscard]] AmUInt16 Read16() const;
[[nodiscard]] AmUInt32 Read32() const;
[[nodiscard]] AmUInt64 Read64() const;
[[nodiscard]] AmString ReadString() const;
AmSize Write8(AmUInt8 value);
AmSize Write16(AmUInt16 value);
AmSize Write32(AmUInt32 value);
AmSize Write64(AmUInt64 value);
AmSize WriteString(const AmString& value);
[[nodiscard]] virtual bool Eof() const = 0;
virtual AmSize Read(AmUInt8Buffer dst, AmSize bytes) const = 0;
virtual AmSize Write(AmConstUInt8Buffer src, AmSize bytes) = 0;
[[nodiscard]] virtual AmSize Length() const = 0;
void Seek(AmSize offset);
virtual void Seek(AmInt64 offset, eFileSeekOrigin origin) = 0;
[[nodiscard]] virtual AmSize Position() const = 0;
[[nodiscard]] virtual AmVoidPtr GetPtr() const = 0;
[[nodiscard]] virtual bool IsValid() const = 0;
virtual void Close() = 0;
};
} // namespace SparkyStudios::Audio::Amplitude
#endif // _AM_IO_FILE_H