2021-11-11 23:12:17 +08:00
|
|
|
#ifndef SC_FILE_H
|
|
|
|
#define SC_FILE_H
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2021-11-11 23:21:07 +08:00
|
|
|
# define SC_PATH_SEPARATOR '\\'
|
2021-11-11 23:12:17 +08:00
|
|
|
#else
|
2021-11-11 23:21:07 +08:00
|
|
|
# define SC_PATH_SEPARATOR '/'
|
2021-11-11 23:12:17 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2021-11-11 23:21:07 +08:00
|
|
|
/**
|
|
|
|
* Indicate if an executable exists using $PATH
|
|
|
|
*
|
|
|
|
* In practice, it is only used to know if a package manager is available on
|
|
|
|
* the system. It is only implemented on Linux.
|
|
|
|
*/
|
2021-11-11 23:12:17 +08:00
|
|
|
bool
|
2021-11-11 23:21:07 +08:00
|
|
|
sc_file_executable_exists(const char *file);
|
2021-11-11 23:12:17 +08:00
|
|
|
#endif
|
|
|
|
|
2021-11-11 23:21:07 +08:00
|
|
|
/**
|
|
|
|
* Return the absolute path of the executable (the scrcpy binary)
|
|
|
|
*
|
|
|
|
* The result must be freed by the caller using free(). It may return NULL on
|
|
|
|
* error.
|
|
|
|
*/
|
2021-11-11 23:12:17 +08:00
|
|
|
char *
|
2021-11-11 23:21:07 +08:00
|
|
|
sc_file_get_executable_path(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the absolute path of a file in the same directory as the executable
|
|
|
|
*
|
|
|
|
* The result must be freed by the caller using free(). It may return NULL on
|
|
|
|
* error.
|
|
|
|
*/
|
2021-11-11 23:12:17 +08:00
|
|
|
char *
|
2021-11-11 23:21:07 +08:00
|
|
|
sc_file_get_local_path(const char *name);
|
2021-11-11 23:12:17 +08:00
|
|
|
|
2021-11-11 23:21:07 +08:00
|
|
|
/**
|
|
|
|
* Indicate if the file exists and is not a directory
|
|
|
|
*/
|
2021-11-11 23:12:17 +08:00
|
|
|
bool
|
2021-11-11 23:21:07 +08:00
|
|
|
sc_file_is_regular(const char *path);
|
2021-11-11 23:12:17 +08:00
|
|
|
|
|
|
|
#endif
|