Implement commits
This commit is contained in:
13
src/utils.c
13
src/utils.c
@@ -1,4 +1,5 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
@@ -9,3 +10,15 @@ int decimal_len(size_t size)
|
||||
|
||||
return floor(log10(size)) + 1;
|
||||
}
|
||||
|
||||
int get_top_folder(char* path, char* top_folder, char* left)
|
||||
{
|
||||
int i = 0;
|
||||
for (;path[i] != '/' && path[i] != '\0'; i++);
|
||||
if (path[i] == '\0') return 0;
|
||||
path[i] = '\0';
|
||||
sprintf(top_folder, "%s", path);
|
||||
sprintf(left, "%s", path + i + 1);
|
||||
path[i] = '/';
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user