Added memory errors for when files aren't found
This commit is contained in:
parent
759b5f6906
commit
58ef0b460f
|
@ -53,11 +53,19 @@ struct window_info
|
||||||
typedef struct window window;
|
typedef struct window window;
|
||||||
|
|
||||||
#define PLATFORM_MEMORY_NO_ERROR 0
|
#define PLATFORM_MEMORY_NO_ERROR 0
|
||||||
|
enum platform_memory_error
|
||||||
|
{
|
||||||
|
PlatformMemory_NoError,
|
||||||
|
PlatformMemory_FileNotFound,
|
||||||
|
|
||||||
|
PlatformMemory_UnknownError, // You should implement handling this when you see it
|
||||||
|
};
|
||||||
|
|
||||||
struct platform_memory_result
|
struct platform_memory_result
|
||||||
{
|
{
|
||||||
u8* Base;
|
u8* Base;
|
||||||
s32 Size;
|
s32 Size;
|
||||||
s32 Error;
|
platform_memory_error Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct texture_buffer
|
struct texture_buffer
|
||||||
|
|
|
@ -93,7 +93,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
r32 FontSize = 14;
|
r32 FontSize = 14;
|
||||||
{
|
{
|
||||||
platform_memory_result FontFile = Context.PlatformReadEntireFile("Anonymous Pro.ttf");
|
platform_memory_result FontFile = Context.PlatformReadEntireFile("Anonymous Pro.ttf");
|
||||||
if (FontFile.Size)
|
if (!FontFile.Error)
|
||||||
{
|
{
|
||||||
bitmap_font* Font = PushStruct(&State->Permanent, bitmap_font);
|
bitmap_font* Font = PushStruct(&State->Permanent, bitmap_font);
|
||||||
|
|
||||||
|
@ -140,7 +140,11 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
|
|
||||||
Font->BitmapTextureHandle = Context.PlatformGetGPUTextureHandle(Font->BitmapMemory,
|
Font->BitmapTextureHandle = Context.PlatformGetGPUTextureHandle(Font->BitmapMemory,
|
||||||
Font->BitmapWidth, Font->BitmapHeight);
|
Font->BitmapWidth, Font->BitmapHeight);
|
||||||
} else {}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO(Peter): How do we want to handle not having a font?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
State->Interface.FontSize = FontSize;
|
State->Interface.FontSize = FontSize;
|
||||||
|
|
|
@ -77,7 +77,10 @@ internal void
|
||||||
LoadAssembly (app_state* State, context Context, char* Path)
|
LoadAssembly (app_state* State, context Context, char* Path)
|
||||||
{
|
{
|
||||||
platform_memory_result TestAssemblyFile = Context.PlatformReadEntireFile(Path);
|
platform_memory_result TestAssemblyFile = Context.PlatformReadEntireFile(Path);
|
||||||
Assert(TestAssemblyFile.Size > 0);
|
if (TestAssemblyFile.Error != PlatformMemory_NoError)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assembly_definition AssemblyDefinition = ParseAssemblyFile(TestAssemblyFile.Base, TestAssemblyFile.Size, &State->Transient);
|
assembly_definition AssemblyDefinition = ParseAssemblyFile(TestAssemblyFile.Base, TestAssemblyFile.Size, &State->Transient);
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,16 @@ typedef CLEANUP_APPLICATION(cleanup_application);
|
||||||
|
|
||||||
// Platform Functions
|
// Platform Functions
|
||||||
|
|
||||||
|
// File IO
|
||||||
|
|
||||||
|
// TODO(Peter):
|
||||||
|
struct directory_listing
|
||||||
|
{
|
||||||
|
string Path;
|
||||||
|
directory_listing* Next;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Font
|
||||||
typedef struct platform_font_info platform_font_info;
|
typedef struct platform_font_info platform_font_info;
|
||||||
|
|
||||||
enum font_weight
|
enum font_weight
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
PLATFORM_READ_ENTIRE_FILE(Win32ReadEntireFile)
|
PLATFORM_READ_ENTIRE_FILE(Win32ReadEntireFile)
|
||||||
{
|
{
|
||||||
platform_memory_result Result = {};
|
platform_memory_result Result = {};
|
||||||
Result.Error = PLATFORM_MEMORY_NO_ERROR;
|
Result.Error = PlatformMemory_NoError;
|
||||||
|
|
||||||
HANDLE FileHandle = CreateFileA (Path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
HANDLE FileHandle = CreateFileA (Path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
||||||
|
@ -30,15 +30,17 @@ PLATFORM_READ_ENTIRE_FILE(Win32ReadEntireFile)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
u32 Error = GetLastError();
|
||||||
|
// TODO(Peter):
|
||||||
Result.Size = 0;
|
Result.Size = 0;
|
||||||
Result.Error = 1;
|
Result.Error = PlatformMemory_UnknownError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloseHandle(FileHandle);
|
CloseHandle(FileHandle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO(Peter): failure
|
Result.Error = PlatformMemory_FileNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
|
@ -131,6 +133,13 @@ PLATFORM_GET_FILE_PATH(Win32SystemDialogueOpenFile)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal directory_listing
|
||||||
|
EnumerateDirectory(char* Path, memory_arena* Storage)
|
||||||
|
{
|
||||||
|
directory_listing Result = {};
|
||||||
|
// TODO(Peter):
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
#define WIN32_FOLDHAUS_FILEIO_H
|
#define WIN32_FOLDHAUS_FILEIO_H
|
||||||
#endif // WIN32_FOLDHAUS_FILEIO_H
|
#endif // WIN32_FOLDHAUS_FILEIO_H
|
2
todo.txt
2
todo.txt
|
@ -18,6 +18,8 @@ x Hot Code Reloading
|
||||||
- Win32 Platform Layer
|
- Win32 Platform Layer
|
||||||
x Capture Mouse Events that start on the window but end outside
|
x Capture Mouse Events that start on the window but end outside
|
||||||
x Mouse up when mouse down was in the window
|
x Mouse up when mouse down was in the window
|
||||||
|
- Enumerate Directory Contents (you started this in win32_foldhaus_fileio.h)
|
||||||
|
-
|
||||||
|
|
||||||
- File Loading
|
- File Loading
|
||||||
- Gracefully handle File Not found
|
- Gracefully handle File Not found
|
||||||
|
|
Loading…
Reference in New Issue