mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-06 16:10:42 +08:00
添加视频压缩代码
This commit is contained in:
39
others/C/video_compression/src/file_utils.c
Normal file
39
others/C/video_compression/src/file_utils.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "file_utils.h"
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
bool file_exists(const char* path) {
|
||||
if (path == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct stat buffer;
|
||||
return stat(path, &buffer) == 0;
|
||||
}
|
||||
|
||||
long file_size(const char* path) {
|
||||
if (path == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct stat buffer;
|
||||
if (stat(path, &buffer) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (long)buffer.st_size;
|
||||
}
|
||||
|
||||
const char* file_extension(const char* path) {
|
||||
if (path == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* dot = strrchr(path, '.');
|
||||
if (dot == NULL || dot == path) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dot;
|
||||
}
|
||||
Reference in New Issue
Block a user