2021-10-24 11:46:30 -04:00
|
|
|
#pragma once
|
|
|
|
|
2024-02-20 21:41:37 -05:00
|
|
|
/**
|
|
|
|
** \defgroup file_js File Interface
|
|
|
|
** Exposes an operating system file I/O API to script.
|
|
|
|
** @{
|
|
|
|
*/
|
|
|
|
|
2024-02-08 20:21:57 -05:00
|
|
|
#include <uv.h>
|
|
|
|
|
2024-03-04 12:23:00 -05:00
|
|
|
/** A JS context. */
|
2023-05-21 17:36:51 -04:00
|
|
|
typedef struct JSContext JSContext;
|
2024-03-04 12:23:00 -05:00
|
|
|
/** A task. */
|
2024-02-08 20:21:57 -05:00
|
|
|
typedef struct _tf_task_t tf_task_t;
|
2021-10-24 11:46:30 -04:00
|
|
|
|
2024-03-04 12:23:00 -05:00
|
|
|
/**
|
|
|
|
** Register the file script interface.
|
|
|
|
** @param context The JS context.
|
|
|
|
*/
|
2021-10-24 11:46:30 -04:00
|
|
|
void tf_file_register(JSContext* context);
|
2024-02-08 20:21:57 -05:00
|
|
|
|
2024-03-04 12:23:00 -05:00
|
|
|
/**
|
|
|
|
** Asynchronously stat() a file.
|
|
|
|
** @param task The running task.
|
|
|
|
** @param path The path to the file to stat().
|
|
|
|
** @param callback A function that will be called with the stat result.
|
|
|
|
** @param user_data User data that will be passed to the callback.
|
|
|
|
*/
|
2024-02-08 20:21:57 -05:00
|
|
|
void tf_file_stat(tf_task_t* task, const char* path, void (*callback)(tf_task_t* task, const char* path, int result, const uv_stat_t* stat, void* user_data), void* user_data);
|
2024-03-04 12:23:00 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
** Asynchronously read a file's contents.
|
|
|
|
** @param task The running task.
|
|
|
|
** @param path The path to the file.
|
|
|
|
** @param callback A callback that will be called with the file contents.
|
|
|
|
** @param user_data User data that will be provided to the callback.
|
|
|
|
*/
|
2024-02-08 20:21:57 -05:00
|
|
|
void tf_file_read(tf_task_t* task, const char* path, void (*callback)(tf_task_t* task, const char* path, int result, const void* data, void* user_data), void* user_data);
|
2024-02-20 21:41:37 -05:00
|
|
|
|
|
|
|
/** @} */
|