base: add iron_is_directory
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <string.h>
|
||||
#ifdef IRON_WINDOWS
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef WITH_AUDIO
|
||||
#include "iron_audio.h"
|
||||
@@ -1554,6 +1556,16 @@ void iron_create_directory(char *path) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool iron_is_directory(char *path) {
|
||||
#ifdef IRON_WINDOWS
|
||||
DWORD attribs = GetFileAttributesA(path);
|
||||
return attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY);
|
||||
#else
|
||||
struct stat st;
|
||||
return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool iron_file_exists(char *path) {
|
||||
iron_file_reader_t reader;
|
||||
if (iron_file_reader_open(&reader, path, IRON_FILE_TYPE_ASSET)) {
|
||||
|
||||
@@ -340,6 +340,7 @@ declare function iron_open_dialog(filter_list: string, default_path: string, ope
|
||||
declare function iron_save_dialog(filter_list: string, default_path: string): string;
|
||||
declare function iron_read_directory(path: string): string;
|
||||
declare function iron_create_directory(path: string): void;
|
||||
declare function iron_is_directory(path: string): bool;
|
||||
declare function iron_file_exists(path: string): bool;
|
||||
declare function iron_delete_file(path: string): void;
|
||||
declare function iron_inflate(bytes: buffer_t, raw: bool): buffer_t;
|
||||
|
||||
Reference in New Issue
Block a user