aboutsummaryrefslogtreecommitdiff
path: root/src/3rdparty/smount/smount.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/smount/smount.c')
-rw-r--r--src/3rdparty/smount/smount.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/3rdparty/smount/smount.c b/src/3rdparty/smount/smount.c
index 6dfc159..c4e2ef0 100644
--- a/src/3rdparty/smount/smount.c
+++ b/src/3rdparty/smount/smount.c
@@ -8,9 +8,9 @@
#define isseparator(c) (c == '/' || c == '\\')
-static sm_Path* sm_newpath(int type, const char* path, sm_Path* next)
+static smtPath* smtnewpath(int type, const char* path, smtPath* next)
{
- sm_Path* temp = (sm_Path*)malloc(sizeof(sm_Path));
+ smtPath* temp = (smtPath*)malloc(sizeof(smtPath));
int len = strlen(path);
temp->path = (char*)malloc(len + 1);
memcpy(temp->path, path, len);
@@ -34,9 +34,9 @@ static const char* mkstr(const char* str)
/**
* Create a new shared contex.
*/
-sm_Shared* sm_newshared()
+smtShared* smtnewshared()
{
- sm_Shared* shared = (sm_Shared*)malloc(sizeof(sm_Shared));
+ smtShared* shared = (smtShared*)malloc(sizeof(smtShared));
shared->mount = 0;
return shared;
}
@@ -72,21 +72,21 @@ static int isdir(const char *path) {
return S_ISDIR(s.st_mode);
}
-int sm_mount(sm_Shared* S, const char *path)
+int smtmount(smtShared* S, const char *path)
{
if (!isdir(path))
{
- return SM_INVALIDMOUNT;
+ return SMT_INVALIDMOUNT;
}
- S->mount = sm_newpath(PATH_DIR, path, 0);
+ S->mount = smtnewpath(PATH_DIR, path, 0);
- return SM_SUCCESS;
+ return SMT_SUCCESS;
}
-void sm_unmount(sm_Shared* S)
+void smtunmount(smtShared* S)
{
- sm_Path* mount = S->mount;
+ smtPath* mount = S->mount;
while (mount)
{
free(mount->path);
@@ -94,19 +94,19 @@ void sm_unmount(sm_Shared* S)
}
}
-int sm_exists(sm_Shared* S, const char *path)
+int smtexists(smtShared* S, const char *path)
{
char* r = concat(S->mount->path, "/", path, 0);
- if (!r) return SM_NOSUCHDIR;
+ if (!r) return SMT_NOSUCHDIR;
struct stat s;
int res = stat(r, &s);
free(r);
if (res == 0)
- return SM_SUCCESS;
- return SM_NOSUCHDIR;
+ return SMT_SUCCESS;
+ return SMT_NOSUCHDIR;
}
-static struct stat sm_getstat(sm_Shared* S, const char*path)
+static struct stat smtgetstat(smtShared* S, const char*path)
{
char* r = concat(S->mount->path, "/", path, 0);
struct stat s = {};
@@ -116,30 +116,30 @@ static struct stat sm_getstat(sm_Shared* S, const char*path)
return s;
}
-int sm_isdir(sm_Shared* S, const char *path)
+int smtisdir(smtShared* S, const char *path)
{
- struct stat s = sm_getstat(S, path);
+ struct stat s = smtgetstat(S, path);
return S_ISDIR(s.st_mode);
}
-int sm_isreg(sm_Shared* S, const char *path)
+int smtisreg(smtShared* S, const char *path)
{
- struct stat s = sm_getstat(S, path);
+ struct stat s = smtgetstat(S, path);
return S_ISREG(s.st_mode);
}
-const char* sm_errstr(int e)
+const char* smterrstr(int e)
{
switch (e)
{
- case SM_INVALIDMOUNT: return "invalid mount directory";
+ case SMT_INVALIDMOUNT: return "invalid mount directory";
default: return "unknown error";
}
}
-void *sm_read(sm_Shared* S, const char *path, unsigned int *size)
+void *smtread(smtShared* S, const char *path, unsigned int *size)
{
- if (!sm_isreg(S, path)) return 0;
+ if (!smtisreg(S, path)) return 0;
int fr = 0;
if (size == 0)
{
@@ -169,32 +169,32 @@ void *sm_read(sm_Shared* S, const char *path, unsigned int *size)
return res;
}
-char* sm_fullpath(sm_Shared* S, const char* path)
+char* smtfullpath(smtShared* S, const char* path)
{
return concat(S->mount->path, "/", path, 0);
}
-int sm_size(sm_Shared* S, const char *path)
+int smtsize(smtShared* S, const char *path)
{
- struct stat s = sm_getstat(S, path);
+ struct stat s = smtgetstat(S, path);
return s.st_size;
}
-void sm_delete(sm_Shared* S, const char *path)
+void smtdelete(smtShared* S, const char *path)
{
- char* name = sm_fullpath(S, path);
+ char* name = smtfullpath(S, path);
remove(name);
free(name);
}
-int sm_write(sm_Shared* S, const char *path, const void *data, int size)
+int smtwrite(smtShared* S, const char *path, const void *data, int size)
{
- char* name = sm_fullpath(S, path);
- if (!name) return SM_NOSUCHDIR;
+ char* name = smtfullpath(S, path);
+ if (!name) return SMT_NOSUCHDIR;
FILE *fp = fopen(name, "wb");
free(name);
- if (!fp) return SM_UNABLEOPEN;
+ if (!fp) return SMT_UNABLEOPEN;
int res = fwrite(data, size, 1, fp);
fclose(fp);
- return (res == 1) ? SM_SUCCESS : SM_CANTWRITE;
+ return (res == 1) ? SMT_SUCCESS : SMT_CANTWRITE;
} \ No newline at end of file