mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-07-08 01:30:39 +08:00
Add ftell
This commit is contained in:
@@ -26,6 +26,8 @@ if (WIN32)
|
|||||||
else()
|
else()
|
||||||
check_symbol_exists(fseeko "stdio.h" HAVE_FSEEKO)
|
check_symbol_exists(fseeko "stdio.h" HAVE_FSEEKO)
|
||||||
check_symbol_exists(fseeko64 "stdio.h" HAVE_FSEEKO64)
|
check_symbol_exists(fseeko64 "stdio.h" HAVE_FSEEKO64)
|
||||||
|
check_symbol_exists(ftello "stdio.h" HAVE_FTELLO)
|
||||||
|
check_symbol_exists(ftello64 "stdio.h" HAVE_FTELLO64)
|
||||||
endif()
|
endif()
|
||||||
check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R)
|
check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R)
|
||||||
if (HAVE_STRERROR_R)
|
if (HAVE_STRERROR_R)
|
||||||
|
|||||||
14
fileop.cpp
14
fileop.cpp
@@ -440,3 +440,17 @@ int fileop::fseek(FILE* f, int64_t offset, int origin) {
|
|||||||
bool fileop::mkdir_for_file(std::string path, int mode) {
|
bool fileop::mkdir_for_file(std::string path, int mode) {
|
||||||
return mkdirs(dirname(path), mode, true);
|
return mkdirs(dirname(path), mode, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t fileop::ftell(FILE* f) {
|
||||||
|
#if _WIN32
|
||||||
|
return ::_ftelli64(f);
|
||||||
|
#else
|
||||||
|
#if HAVE_FTELLO64
|
||||||
|
return ::ftello64(f);
|
||||||
|
#elif HAVE_FTELLO
|
||||||
|
return ::ftello(f);
|
||||||
|
#else
|
||||||
|
return ::ftell(f);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
6
fileop.h
6
fileop.h
@@ -148,5 +148,11 @@ namespace fileop {
|
|||||||
* @return true if file's directory is exists now.
|
* @return true if file's directory is exists now.
|
||||||
*/
|
*/
|
||||||
bool mkdir_for_file(std::string path, int mode);
|
bool mkdir_for_file(std::string path, int mode);
|
||||||
|
/**
|
||||||
|
* @brief Gets the current position of a file pointer.
|
||||||
|
* @param f Target FILE structure.
|
||||||
|
* @return The current position
|
||||||
|
*/
|
||||||
|
int64_t ftell(FILE* f);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,3 +10,5 @@
|
|||||||
#cmakedefine HAVE_SSCANF_S @HAVE_SSCANF_S@
|
#cmakedefine HAVE_SSCANF_S @HAVE_SSCANF_S@
|
||||||
#cmakedefine HAVE_FSEEKO @HAVE_FSEEKO@
|
#cmakedefine HAVE_FSEEKO @HAVE_FSEEKO@
|
||||||
#cmakedefine HAVE_FSEEKO64 @HAVE_FSEEKO64@
|
#cmakedefine HAVE_FSEEKO64 @HAVE_FSEEKO64@
|
||||||
|
#cmakedefine HAVE_FTELLO @HAVE_FTELLO@
|
||||||
|
#cmakedefine HAVE_FTELLO64 @HAVE_FTELLO64@
|
||||||
|
|||||||
Reference in New Issue
Block a user