summaryrefslogtreecommitdiffhomepage
path: root/examples/core/core_drop_files.c
diff options
context:
space:
mode:
authorRay <[email protected]>2022-06-11 23:24:13 +0200
committerRay <[email protected]>2022-06-11 23:24:13 +0200
commitb8f67c628553cb9199f51efc9b20eb5991d58e8f (patch)
tree9a5dd90da94402c4505b4e6952d0f831743ee7ee /examples/core/core_drop_files.c
parentf7744404d672743b01970429f7c5f4c9136f2c7c (diff)
downloadraylib-b8f67c628553cb9199f51efc9b20eb5991d58e8f.tar.gz
raylib-b8f67c628553cb9199f51efc9b20eb5991d58e8f.zip
WARNING: BREAKING: REDESIGNED: Filepath loading API
REDESIGNED: `LoadDirectoryFiles()` ADDED: `LoadDirectoryFilesEx()` REDESIGNED: `LoadDroppedFiles()` ADDED: `IsPathFile()` This BIG BREAKING change simplifies the functions and gives more control to the user: - A new `struct FilePathList` has been added to avoid exposing complex pointers. - User is responsible of memory loading/unloading - Filepaths loading support recursive directories and file extension filters
Diffstat (limited to 'examples/core/core_drop_files.c')
-rw-r--r--examples/core/core_drop_files.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/core/core_drop_files.c b/examples/core/core_drop_files.c
index 129ced10..0a1a71e9 100644
--- a/examples/core/core_drop_files.c
+++ b/examples/core/core_drop_files.c
@@ -22,8 +22,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files");
- int count = 0;
- char **droppedFiles = { 0 };
+ FilePathList droppedFiles = { 0 };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -35,7 +34,11 @@ int main(void)
//----------------------------------------------------------------------------------
if (IsFileDropped())
{
- droppedFiles = LoadDroppedFiles(&count);
+ // Is some files have been previously loaded, unload them
+ if (droppedFiles.count > 0) UnloadDroppedFiles(droppedFiles);
+
+ // Load new dropped files
+ droppedFiles = LoadDroppedFiles();
}
//----------------------------------------------------------------------------------
@@ -55,7 +58,7 @@ int main(void)
if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));
- DrawText(droppedFiles[i], 120, 100 + 40*i, 10, GRAY);
+ DrawText(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY);
}
DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY);
@@ -67,7 +70,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- UnloadDroppedFiles(); // Clear internal buffers
+ UnloadDroppedFiles(droppedFiles); // Unload files memory
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------