Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sources/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ __declspec(dllimport) unsigned long __stdcall GetLastError(void);

#define INVALID_HANDLE_VALUE ((void *)(__int64)-1)

int dir_exists(const char *dirname) {
// Windows-specific placeholder
return -1;
}

directory open_dir(const char *dirname) {
char pattern[1024];
strcpy(pattern, dirname);
Expand Down Expand Up @@ -84,6 +89,16 @@ void close_dir(directory *dir) {
#include <sys/stat.h>
#include <sys/types.h>

int dir_exists(const char *dirname) {
struct stat dir_info;

if (stat(dirname, &dir_info) != 0){
return 0;
}

return S_ISDIR(dir_info.st_mode);
}

directory open_dir(const char *dirname) {
directory dir;
dir.handle = opendir(dirname);
Expand Down
1 change: 1 addition & 0 deletions sources/dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ typedef struct file {
directory open_dir(const char *dirname);
file read_next_file(directory *dir);
void close_dir(directory *dir);
int dir_exists(const char* dirname);

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions sources/kong.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ int main(int argc, char **argv) {
check(mode == MODE_MODECHECK, context, "Wrong parameter syntax");
check(inputs_size > 0, context, "no input parameters found");
check(output != NULL, context, "output parameter not found");
check(dir_exists(output) == 1, context, "output directory doesn't exist or isn't a directory");
check(api != API_DEFAULT, context, "api parameter not found");

names_init();
Expand Down
Loading