diff --git a/dap-sdk/core/include/dap_file_utils.h b/dap-sdk/core/include/dap_file_utils.h index b834d111f2e883a4c3a12552ef1fe24e9a186b70..3bddee20a53f5c6612d2cc302c269873da95d41c 100755 --- a/dap-sdk/core/include/dap_file_utils.h +++ b/dap-sdk/core/include/dap_file_utils.h @@ -72,6 +72,16 @@ extern "C" { bool dap_valid_ascii_symbols(const char *a_dir_path); +/** + * @brief dap_file_simple_test + * test if file presented without specific file system attributic + * + * @param a_file_path + * @return true + * @return false + */ +bool dap_file_simple_test(const char * a_file_path); + /** * Check the file for exists * diff --git a/dap-sdk/core/src/dap_file_utils.c b/dap-sdk/core/src/dap_file_utils.c index ef6c15699c5bd3cd016580589b7205aa30220a97..c9e6d2776e77daa31416d2491970bbb63e86a79e 100755 --- a/dap-sdk/core/src/dap_file_utils.c +++ b/dap-sdk/core/src/dap_file_utils.c @@ -66,6 +66,30 @@ bool dap_valid_ascii_symbols(const char *a_string) return true; } +/** + * Check the file for exists + * + * @a_file_path filename pathname + * @return true, if file exists + */ +bool dap_file_simple_test(const char * a_file_path) +{ + if(!a_file_path) + return false; +#ifdef _WIN32 + int attr = GetFileAttributesA(a_file_path); + if(attr != -1) + return true; +#else + struct stat st; + if (!stat(a_file_path, &st)) { + if (S_ISREG(st.st_mode)) + return true; + } +#endif + return false; +} + /** * Check the file for exists *