Harmonic Flow Framework (libhffwk)
Cross platform C++ 2D Game Engine Framework
Storage.cpp
1 /*
2  Harmonic Flow Framework
3  Copyright (C) 2011-2018 Andreas Widen <andreas@harmonicflow.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "Storage.h"
22 
23 using namespace HFCore;
24 
25 #include "debug/CrtDbgNew.h"
26 
28 {
29 }
30 
32 {
33 }
34 
36  int32_hf *pSizeBytesOut)
37 {
38  Result result = STORAGE_FAIL;
39 
40  HF_FileHandle hFile;
41  Result openResult = FileOpen(pFilePath, STORAGE_MODE_READ |
42  STORAGE_MUST_EXIST, &hFile);
43  if ((openResult == STORAGE_OK) && pSizeBytesOut)
44  {
45  *pSizeBytesOut = FileGetSize(hFile);
46  result = STORAGE_OK;
47  }
48  if (openResult == STORAGE_OK) FileClose(hFile);
49 
50  return result;
51 }
Storage. Must exist.
Definition: Storage.h:57
int int32_hf
A type definition for int.
Definition: HFDataTypes.h:349
virtual ~Storage()
Destructor.
Definition: Storage.cpp:31
Interface for Storage and File IO stuff.
Storage()
Constructor.
Definition: Storage.cpp:27
char int8_hf
A type definition for char.
Definition: HFDataTypes.h:329
int32_hf HF_FileHandle
A type definition for int32_hf used as File IO handle.
Definition: HFDataTypes.h:381
Storage mode: Read.
Definition: Storage.h:53
Result
Storage result enum.
Definition: Storage.h:42
Definition: Actor.h:34
virtual Result FileClose(HF_FileHandle fileHandle)=0
Close a file.
virtual Result FileOpen(const int8_hf *pFilePathUtf8, int32_hf modeFlags, HF_FileHandle *pFileHandleOut)=0
Open a file.
virtual int32_hf FileGetSize(HF_FileHandle openFileHandle)=0
Get the size of file in bytes.