From b8f67c628553cb9199f51efc9b20eb5991d58e8f Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 11 Jun 2022 23:24:13 +0200 Subject: 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 --- examples/core/core_drop_files.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'examples/core/core_drop_files.c') 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 //-------------------------------------------------------------------------------------- -- cgit v1.2.3