Skip to content

Commit

Permalink
Promote cf_fs_init/destroy to public API
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyGaul committed Jul 4, 2024
1 parent 8366c5f commit 0ff1599
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 31 deletions.
2 changes: 2 additions & 0 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ This is a list of all functions in Cute Framework organized by categories. This
- [cf_fs_close](/file/cf_fs_close.md)
- [cf_fs_create_directory](/file/cf_fs_create_directory.md)
- [cf_fs_create_file](/file/cf_fs_create_file.md)
- [cf_fs_destroy](/file/cf_fs_destroy.md)
- [cf_fs_dismount](/file/cf_fs_dismount.md)
- [cf_fs_enumerate_directory](/file/cf_fs_enumerate_directory.md)
- [cf_fs_eof](/file/cf_fs_eof.md)
Expand All @@ -649,6 +650,7 @@ This is a list of all functions in Cute Framework organized by categories. This
- [cf_fs_get_backend_specific_error_message](/file/cf_fs_get_backend_specific_error_message.md)
- [cf_fs_get_base_directory](/file/cf_fs_get_base_directory.md)
- [cf_fs_get_user_directory](/file/cf_fs_get_user_directory.md)
- [cf_fs_init](/file/cf_fs_init.md)
- [cf_fs_mount](/file/cf_fs_mount.md)
- [cf_fs_open_file_for_append](/file/cf_fs_open_file_for_append.md)
- [cf_fs_open_file_for_read](/file/cf_fs_open_file_for_read.md)
Expand Down
26 changes: 26 additions & 0 deletions docs/file/cf_fs_destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[](../header.md ':include')

# cf_fs_destroy

Category: [file](/api_reference?id=file)
GitHub: [cute_file_system.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_file_system.h)
---

Destroys the [Virtual File System](https://randygaul.github.io/cute_framework/#/topics/virtual_file_system).

```cpp
void cf_fs_destroy();
```

Parameters | Description
--- | ---
argv0 | The first command-line argument passed into your `main` function.

## Remarks

Cleans up all static memory used by [cf_fs_init](/file/cf_fs_init.md). You probably don't need to call this function,
as `cf_app_destroy` already does this for you.

## Related Pages

[cf_fs_init](/file/cf_fs_init.md)
28 changes: 28 additions & 0 deletions docs/file/cf_fs_init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[](../header.md ':include')

# cf_fs_init

Category: [file](/api_reference?id=file)
GitHub: [cute_file_system.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_file_system.h)
---

Initializes the [Virtual File System](https://randygaul.github.io/cute_framework/#/topics/virtual_file_system).

```cpp
CF_Result cf_fs_init(const char* argv0);
```
Parameters | Description
--- | ---
argv0 | The first command-line argument passed into your `main` function.
## Remarks
This function is automatically called by `cf_app_make`; for most use cases you do not
need to call this function. However, sometimes it's convenient to make tools that crawl
over files without the need for a full application window. In this case simply call this
function to enable all the `cf_fs_` functions.
## Related Pages
[cf_fs_destroy](/file/cf_fs_destroy.md)
10 changes: 10 additions & 0 deletions include/cute.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
#ifndef CF_H
#define CF_H

/* Special thanks contributor list
*
* ogam
* Jon Stevens
* Kariem
* Bullno1
*
*/


#include "cute_aabb_tree.h"
#include "cute_alloc.h"
#include "cute_app.h"
Expand Down
24 changes: 24 additions & 0 deletions include/cute_file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,30 @@ CF_API const char* CF_CALL cf_fs_get_backend_specific_error_message();
*/
CF_API const char* CF_CALL cf_fs_get_actual_path(const char* virtual_path);

/**
* @function cf_fs_init
* @category file
* @brief Initializes the [Virtual File System](https://randygaul.github.io/cute_framework/#/topics/virtual_file_system).
* @param argv0 The first command-line argument passed into your `main` function.
* @remarks This function is automatically called by `cf_app_make`; for most use cases you do not
* need to call this function. However, sometimes it's convenient to make tools that crawl
* over files without the need for a full application window. In this case simply call this
* function to enable all the `cf_fs_***` functions.
* @related cf_fs_init cf_fs_destroy
*/
CF_API CF_Result CF_CALL cf_fs_init(const char* argv0);

/**
* @function cf_fs_destroy
* @category file
* @brief Destroys the [Virtual File System](https://randygaul.github.io/cute_framework/#/topics/virtual_file_system).
* @param argv0 The first command-line argument passed into your `main` function.
* @remarks Cleans up all static memory used by `cf_fs_init`. You probably don't need to call this function,
* as `cf_app_destroy` already does this for you.
* @related cf_fs_init cf_fs_destroy
*/
CF_API void CF_CALL cf_fs_destroy();

#ifdef __cplusplus
}
#endif // __cplusplus
Expand Down
2 changes: 0 additions & 2 deletions samples/docs_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ using namespace Cute;

// Parses all the Cute headers and generates documentation pages in .md format.

#include "internal/cute_file_system_internal.h"

const char* g_relative_path;
const char* get_relative_path()
{
Expand Down
1 change: 0 additions & 1 deletion src/cute_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <internal/cute_alloc_internal.h>
#include <internal/cute_app_internal.h>
#include <internal/cute_file_system_internal.h>
#include <internal/cute_input_internal.h>
#include <internal/cute_graphics_internal.h>
#include <internal/cute_draw_internal.h>
Expand Down
1 change: 0 additions & 1 deletion src/cute_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <internal/cute_alloc_internal.h>
#include <internal/cute_app_internal.h>
#include <internal/cute_file_system_internal.h>

#include <physfs/physfs.h>

Expand Down
25 changes: 0 additions & 25 deletions src/internal/cute_file_system_internal.h

This file was deleted.

1 change: 0 additions & 1 deletion test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#define PICO_UNIT_IMPLEMENTATION
#include <pico/pico_unit.h>

#include <internal/cute_file_system_internal.h>
#include <cute.h>

TEST_SUITE(test_aabb);
Expand Down
1 change: 0 additions & 1 deletion test/test_png_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "test_harness.h"

#include <internal/cute_file_system_internal.h> // fs_init / fs_destroy
#include <cute.h>
using namespace Cute;

Expand Down

0 comments on commit 0ff1599

Please sign in to comment.