summaryrefslogtreecommitdiffstats
path: root/src/sord_validate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sord_validate.c')
-rw-r--r--src/sord_validate.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/sord_validate.c b/src/sord_validate.c
index 4951534..13fc16f 100644
--- a/src/sord_validate.c
+++ b/src/sord_validate.c
@@ -8,6 +8,7 @@
#include <serd/serd.h>
#include <sord/sord.h>
+#include <zix/filesystem.h>
#if USE_PCRE2
# if defined(__clang__)
@@ -23,10 +24,6 @@
# endif
#endif
-#ifdef _WIN32
-# include <windows.h>
-#endif
-
#include <inttypes.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -120,18 +117,6 @@ print_usage(const char* name, bool error)
return error ? 1 : 0;
}
-static uint8_t*
-absolute_path(const uint8_t* path)
-{
-#ifdef _WIN32
- char* out = (char*)malloc(MAX_PATH);
- GetFullPathName((const char*)path, MAX_PATH, out, NULL);
- return (uint8_t*)out;
-#else
- return (uint8_t*)realpath((const char*)path, NULL);
-#endif
-}
-
SORD_LOG_FUNC(2, 3) static int
errorf(const SordQuad quad, const char* fmt, ...)
{
@@ -734,7 +719,7 @@ main(int argc, char** argv)
for (; a < argc; ++a) {
const uint8_t* input = (const uint8_t*)argv[a];
uint8_t* rel_in_path = serd_file_uri_parse(input, NULL);
- uint8_t* in_path = absolute_path(rel_in_path);
+ char* in_path = zix_canonical_path(NULL, (char*)rel_in_path);
free(rel_in_path);
if (!in_path) {
@@ -744,16 +729,17 @@ main(int argc, char** argv)
SerdURI base_uri;
SerdNode base_uri_node =
- serd_node_new_file_uri(in_path, NULL, &base_uri, true);
+ serd_node_new_file_uri((const uint8_t*)in_path, NULL, &base_uri, true);
serd_env_set_base_uri(env, &base_uri_node);
- const SerdStatus st = serd_reader_read_file(reader, in_path);
+ const SerdStatus st =
+ serd_reader_read_file(reader, (const uint8_t*)in_path);
if (st) {
fprintf(stderr, "error reading %s: %s\n", in_path, serd_strerror(st));
}
serd_node_free(&base_uri_node);
- free(in_path);
+ zix_free(NULL, in_path);
}
serd_reader_free(reader);
serd_env_free(env);