Browse Source

libobs/util: Add function to get file size

From pull request: jp9000/obs-studio#374
adray 10 years ago
parent
commit
3e6db990fc
2 changed files with 14 additions and 0 deletions
  1. 12 0
      libobs/util/platform.c
  2. 2 0
      libobs/util/platform.h

+ 12 - 0
libobs/util/platform.c

@@ -282,6 +282,18 @@ cleanup:
 	return success;
 }
 
+int64_t os_get_file_size(const char *path)
+{
+	FILE* f = os_fopen(path, "rb");
+	if (!f)
+		return -1;
+
+	int64_t sz = os_fgetsize(f);
+	fclose(f);
+
+	return sz;
+}
+
 size_t os_mbs_to_wcs(const char *str, size_t len, wchar_t *dst, size_t dst_size)
 {
 	size_t out_len;

+ 2 - 0
libobs/util/platform.h

@@ -51,6 +51,8 @@ EXPORT char *os_quick_read_mbs_file(const char *path);
 EXPORT bool os_quick_write_mbs_file(const char *path, const char *str,
 		size_t len);
 
+EXPORT int64_t os_get_file_size(const char *path);
+
 EXPORT size_t os_mbs_to_wcs(const char *str, size_t str_len, wchar_t *dst,
 		size_t dst_size);
 EXPORT size_t os_utf8_to_wcs(const char *str, size_t len, wchar_t *dst,