Skip to content

Commit 0249edf

Browse files
committed
ADDED: example: core_directory_files
1 parent 4cfae99 commit 0249edf

File tree

9 files changed

+689
-12
lines changed

9 files changed

+689
-12
lines changed

examples/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ CORE = \
515515
core/core_custom_frame_control \
516516
core/core_custom_logging \
517517
core/core_delta_time \
518+
core/core_directory_files \
518519
core/core_drop_files \
519520
core/core_high_dpi \
520521
core/core_input_actions \

examples/Makefile.Web

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ CORE = \
515515
core/core_custom_frame_control \
516516
core/core_custom_logging \
517517
core/core_delta_time \
518+
core/core_directory_files \
518519
core/core_drop_files \
519520
core/core_high_dpi \
520521
core/core_input_actions \
@@ -740,6 +741,9 @@ core/core_custom_logging: core/core_custom_logging.c
740741
core/core_delta_time: core/core_delta_time.c
741742
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
742743

744+
core/core_directory_files: core/core_directory_files.c
745+
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
746+
743747
core/core_drop_files: core/core_drop_files.c
744748
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
745749

examples/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ You may find it easier to use than other toolchains, especially when it comes to
1717
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
1818
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
1919

20-
## EXAMPLES COLLECTION [TOTAL: 174]
20+
## EXAMPLES COLLECTION [TOTAL: 175]
2121

22-
### category: core [40]
22+
### category: core [41]
2323

2424
Examples using raylib[core](../src/rcore.c) platform functionality like window creation, inputs, drawing modes and system functionality.
2525

@@ -65,6 +65,7 @@ Examples using raylib[core](../src/rcore.c) platform functionality like window c
6565
| [core_render_texture](core/core_render_texture.c) | <img src="core/core_render_texture.png" alt="core_render_texture" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
6666
| [core_undo_redo](core/core_undo_redo.c) | <img src="core/core_undo_redo.png" alt="core_undo_redo" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.6 | [Ramon Santamaria](https://github.com/raysan5) |
6767
| [core_input_actions](core/core_input_actions.c) | <img src="core/core_input_actions.png" alt="core_input_actions" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Jett](https://github.com/JettMonstersGoBoom) |
68+
| [core_directory_files](core/core_directory_files.c) | <img src="core/core_directory_files.png" alt="core_directory_files" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Hugo ARNAL](https://github.com/hugoarnal) |
6869

6970
### category: shapes [25]
7071

@@ -84,8 +85,8 @@ Examples using raylib shapes drawing functionality, provided by raylib [shapes](
8485
| [shapes_following_eyes](shapes/shapes_following_eyes.c) | <img src="shapes/shapes_following_eyes.png" alt="shapes_following_eyes" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
8586
| [shapes_easings_ball](shapes/shapes_easings_ball.c) | <img src="shapes/shapes_easings_ball.png" alt="shapes_easings_ball" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
8687
| [shapes_easings_box](shapes/shapes_easings_box.c) | <img src="shapes/shapes_easings_box.png" alt="shapes_easings_box" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
87-
| [shapes_recursive_tree](shapes/shapes_recursive_tree.c) | <img src="shapes/shapes_recursive_tree.png" alt="shapes_recursive_tree" width="80"> | ⭐⭐⭐☆ | 5.6-dev | 5.6-dev| [Jopestpe](https://github.com/jopestpe) |
8888
| [shapes_easings_rectangles](shapes/shapes_easings_rectangles.c) | <img src="shapes/shapes_easings_rectangles.png" alt="shapes_easings_rectangles" width="80"> | ⭐⭐⭐☆ | 2.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
89+
| [shapes_recursive_tree](shapes/shapes_recursive_tree.c) | <img src="shapes/shapes_recursive_tree.png" alt="shapes_recursive_tree" width="80"> | ⭐⭐⭐☆ | 5.6-dev | 5.6-dev | [Jopestpe](https://github.com/jopestpe) |
8990
| [shapes_ring_drawing](shapes/shapes_ring_drawing.c) | <img src="shapes/shapes_ring_drawing.png" alt="shapes_ring_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
9091
| [shapes_circle_sector_drawing](shapes/shapes_circle_sector_drawing.c) | <img src="shapes/shapes_circle_sector_drawing.png" alt="shapes_circle_sector_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
9192
| [shapes_rounded_rectangle_drawing](shapes/shapes_rounded_rectangle_drawing.c) | <img src="shapes/shapes_rounded_rectangle_drawing.png" alt="shapes_rounded_rectangle_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*******************************************************************************************
2+
*
3+
* raylib [core] example - directory files
4+
*
5+
* Example complexity rating: [★☆☆☆] 1/4
6+
*
7+
* Example originally created with raylib 5.5, last time updated with raylib 5.6
8+
*
9+
* Example contributed by Hugo ARNAL (@hugoarnal) and reviewed by Ramon Santamaria (@raysan5)
10+
*
11+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
12+
* BSD-like license that allows static linking with closed source software
13+
*
14+
* Copyright (c) 2025 Hugo ARNAL (@hugoarnal)
15+
*
16+
********************************************************************************************/
17+
18+
#include "raylib.h"
19+
20+
//------------------------------------------------------------------------------------
21+
// Program main entry point
22+
//------------------------------------------------------------------------------------
23+
int main(void)
24+
{
25+
// Initialization
26+
//--------------------------------------------------------------------------------------
27+
const int screenWidth = 800;
28+
const int screenHeight = 450;
29+
30+
InitWindow(screenWidth, screenHeight, "raylib [core] example - directory files");
31+
32+
char *directory = ".";
33+
FilePathList files = LoadDirectoryFiles(directory);
34+
35+
SetTargetFPS(60);
36+
//--------------------------------------------------------------------------------------
37+
38+
// Main game loop
39+
while (!WindowShouldClose()) // Detect window close button or ESC key
40+
{
41+
// Update
42+
//----------------------------------------------------------------------------------
43+
44+
// Draw
45+
//----------------------------------------------------------------------------------
46+
BeginDrawing();
47+
48+
ClearBackground(RAYWHITE);
49+
50+
DrawText(TextFormat("Files in directory \"%s\":", directory), 100, 40, 20, DARKGRAY);
51+
52+
for (int i = 0; i < (int)files.count; i++) {
53+
float alpha = i % 2 == 0 ? 0.5f : 0.3f;
54+
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, alpha));
55+
56+
DrawText(files.paths[i], 120, 100 + 40*i, 10, GRAY);
57+
}
58+
EndDrawing();
59+
//----------------------------------------------------------------------------------
60+
}
61+
62+
// De-Initialization
63+
//--------------------------------------------------------------------------------------
64+
65+
UnloadDirectoryFiles(files);
66+
67+
CloseWindow(); // Close window and OpenGL context
68+
//--------------------------------------------------------------------------------------
69+
70+
return 0;
71+
}
4.28 KB
Loading

examples/examples_list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ core;core_high_dpi;★★☆☆;5.0;5.5;2025;2025;"Jonathan Marler";@marler8997
4747
core;core_render_texture;★☆☆☆;5.6-dev;5.6-dev;2025;2025;"Ramon Santamaria";@raysan5
4848
core;core_undo_redo;★★★☆;5.5;5.6;2025;2025;"Ramon Santamaria";@raysan5
4949
core;core_input_actions;★★☆☆;5.5;5.6;2025;2025;"Jett";@JettMonstersGoBoom
50+
core;core_directory_files;★☆☆☆;5.5;5.6;2025;2025;"Hugo ARNAL";@hugoarnal
5051
shapes;shapes_basic_shapes;★☆☆☆;1.0;4.2;2014;2025;"Ramon Santamaria";@raysan5
5152
shapes;shapes_bouncing_ball;★☆☆☆;2.5;2.5;2013;2025;"Ramon Santamaria";@raysan5
5253
shapes;shapes_bullet_hell;★☆☆☆;5.6;5.6;2025;2025;"Zero";@zerohorsepower

0 commit comments

Comments
 (0)