mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-06-06 05:08:45 +08:00
Initialize
This commit is contained in:
41
cfileop.cpp
Normal file
41
cfileop.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "cfileop.h"
|
||||
#include "fileop.h"
|
||||
#include "cpp2c.h"
|
||||
|
||||
int fileop_exists(const char* fn) {
|
||||
if (!fn) return 0;
|
||||
return fileop::exists(fn) ? 1 : 0;
|
||||
}
|
||||
|
||||
int fileop_remove(const char* fn) {
|
||||
if (!fn) return 0;
|
||||
return fileop::remove(fn) ? 1 : 0;
|
||||
}
|
||||
|
||||
char* fileop_dirname(const char* fn) {
|
||||
if (!fn) return nullptr;
|
||||
auto re = fileop::dirname(fn);
|
||||
char* tmp = nullptr;
|
||||
return cpp2c::string2char(re, tmp) ? tmp : nullptr;
|
||||
}
|
||||
|
||||
int fileop_is_url(const char* fn, int* re) {
|
||||
if (!fn || !re) return 0;
|
||||
*re = fileop::is_url(fn) ? 1 : 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* fileop_basename(const char* fn) {
|
||||
if (!fn) return nullptr;
|
||||
auto re = fileop::basename(fn);
|
||||
char* tmp = nullptr;
|
||||
return cpp2c::string2char(re, tmp) ? tmp : nullptr;
|
||||
}
|
||||
|
||||
int fileop_parse_size(const char* size, size_t* fs, int is_byte) {
|
||||
if (!size || !fs) return 0;
|
||||
size_t tmp;
|
||||
auto re = fileop::parse_size(size, tmp, is_byte);
|
||||
if (re) *fs = tmp;
|
||||
return re ? 1 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user