mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-09-25 20:59:20 +03:00
hamcorebuilder: Use libhamcore to build archive
https://github.com/SoftEtherVPN/libhamcore
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
#include "FileSystem.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
|
||||
ENTRIES *EnumEntries(const char *path)
|
||||
{
|
||||
@ -121,83 +119,6 @@ void FreeEntries(ENTRIES *entries)
|
||||
free(entries);
|
||||
}
|
||||
|
||||
FILE *FileOpen(const char *path, const bool write)
|
||||
{
|
||||
if (!path)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fopen(path, write ? "wb" : "rb");
|
||||
}
|
||||
|
||||
bool FileClose(FILE *file)
|
||||
{
|
||||
if (!file)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return fclose(file) == 0;
|
||||
}
|
||||
|
||||
bool FileRead(FILE *file, void *dst, const size_t size)
|
||||
{
|
||||
if (!file || !dst || size == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return fread(dst, 1, size, file) == size;
|
||||
}
|
||||
|
||||
bool FileWrite(FILE *file, const void *src, const size_t size)
|
||||
{
|
||||
if (!file || !src || size == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return fwrite(src, 1, size, file) == size;
|
||||
}
|
||||
|
||||
size_t FileSize(const char *path)
|
||||
{
|
||||
if (!path)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct stat st;
|
||||
if (stat(path, &st) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return st.st_size;
|
||||
}
|
||||
|
||||
char *PathRelativeToBase(char *full, const char *base)
|
||||
{
|
||||
if (!full || !base)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strstr(full, base) != &full[0])
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
full += strlen(base);
|
||||
if (full[0] == '/')
|
||||
{
|
||||
++full;
|
||||
}
|
||||
|
||||
return full;
|
||||
}
|
||||
|
||||
#ifndef OS_WINDOWS
|
||||
bool IsWindowsExtension(const char *extension)
|
||||
{
|
||||
|
Reference in New Issue
Block a user