fx.io: convert to assembly build system
This commit is contained in:
+37
-17
@@ -1,7 +1,7 @@
|
||||
#include <fx/core/error.h>
|
||||
#include <fx/core/status.h>
|
||||
#include <fx/io/file.h>
|
||||
#include <errno.h>
|
||||
#include <fx/error.h>
|
||||
#include <fx/io/file.h>
|
||||
#include <fx/status.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
enum fx_status fx_status_from_errno(int error, enum fx_status default_value)
|
||||
@@ -35,40 +35,53 @@ enum fx_status fx_status_from_errno(int error, enum fx_status default_value)
|
||||
}
|
||||
|
||||
fx_result fx_result_from_errno_with_filepath(
|
||||
int error, const char *path, enum fx_status default_value)
|
||||
int error,
|
||||
const char *path,
|
||||
enum fx_status default_value)
|
||||
{
|
||||
switch (error) {
|
||||
case 0:
|
||||
return FX_RESULT_SUCCESS;
|
||||
case ENOENT:
|
||||
return FX_RESULT_STATUS_WITH_STRING(
|
||||
FX_ERR_NO_ENTRY, "Path @i{%s} does not exist", path);
|
||||
FX_ERR_NO_ENTRY,
|
||||
"Path @i{%s} does not exist",
|
||||
path);
|
||||
case ENOTDIR:
|
||||
return FX_RESULT_STATUS_WITH_STRING(
|
||||
FX_ERR_NOT_DIRECTORY, "Path @i{%s} is not a directory",
|
||||
FX_ERR_NOT_DIRECTORY,
|
||||
"Path @i{%s} is not a directory",
|
||||
path);
|
||||
case EISDIR:
|
||||
return FX_RESULT_STATUS_WITH_STRING(
|
||||
FX_ERR_IS_DIRECTORY, "Path @i{%s} is a directory", path);
|
||||
FX_ERR_IS_DIRECTORY,
|
||||
"Path @i{%s} is a directory",
|
||||
path);
|
||||
case EPERM:
|
||||
case EACCES:
|
||||
return FX_RESULT_STATUS_WITH_STRING(
|
||||
FX_ERR_PERMISSION_DENIED,
|
||||
"Permission denied while accessing path @i{%s}", path);
|
||||
"Permission denied while accessing path @i{%s}",
|
||||
path);
|
||||
default:
|
||||
return FX_RESULT_STATUS(fx_status_from_errno(error, default_value));
|
||||
return FX_RESULT_STATUS(
|
||||
fx_status_from_errno(error, default_value));
|
||||
}
|
||||
|
||||
return FX_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
fx_result fx_result_from_errno_with_subfilepath(
|
||||
int error, const char *path, const char *dir_path,
|
||||
int error,
|
||||
const char *path,
|
||||
const char *dir_path,
|
||||
enum fx_status default_value)
|
||||
{
|
||||
if (!dir_path) {
|
||||
return fx_result_propagate(fx_result_from_errno_with_filepath(
|
||||
error, path, default_value));
|
||||
error,
|
||||
path,
|
||||
default_value));
|
||||
}
|
||||
|
||||
switch (error) {
|
||||
@@ -77,17 +90,20 @@ fx_result fx_result_from_errno_with_subfilepath(
|
||||
case ENOENT:
|
||||
return FX_RESULT_STATUS_WITH_STRING(
|
||||
FX_ERR_NO_ENTRY,
|
||||
"Path @i{%s} in directory @i{%s} does not exist", path,
|
||||
"Path @i{%s} in directory @i{%s} does not exist",
|
||||
path,
|
||||
dir_path);
|
||||
case ENOTDIR:
|
||||
return FX_RESULT_STATUS_WITH_STRING(
|
||||
FX_ERR_NOT_DIRECTORY,
|
||||
"Path @i{%s} in directory @i{%s} is not a directory",
|
||||
path, dir_path);
|
||||
path,
|
||||
dir_path);
|
||||
case EISDIR:
|
||||
return FX_RESULT_STATUS_WITH_STRING(
|
||||
FX_ERR_IS_DIRECTORY,
|
||||
"Path @i{%s} in directory @i{%s} is a directory", path,
|
||||
"Path @i{%s} in directory @i{%s} is a directory",
|
||||
path,
|
||||
dir_path);
|
||||
case EPERM:
|
||||
case EACCES:
|
||||
@@ -95,15 +111,19 @@ fx_result fx_result_from_errno_with_subfilepath(
|
||||
FX_ERR_PERMISSION_DENIED,
|
||||
"Permission denied while accessing path @i{%s} in "
|
||||
"directory @i{%s}",
|
||||
path, dir_path);
|
||||
path,
|
||||
dir_path);
|
||||
default:
|
||||
return FX_RESULT_STATUS(fx_status_from_errno(error, default_value));
|
||||
return FX_RESULT_STATUS(
|
||||
fx_status_from_errno(error, default_value));
|
||||
}
|
||||
|
||||
return FX_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
enum fx_status fx_file_info_from_stat(const struct stat *st, struct fx_file_info *out)
|
||||
enum fx_status fx_file_info_from_stat(
|
||||
const struct stat *st,
|
||||
struct fx_file_info *out)
|
||||
{
|
||||
out->length = st->st_size;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user