]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Put the human_size() function in util.c
authorScott Baker <scott@perturb.org>
Sat, 5 Jun 2021 03:28:55 +0000 (20:28 -0700)
committerW. Felix Handte <w@felixhandte.com>
Thu, 10 Jun 2021 16:53:07 +0000 (12:53 -0400)
programs/fileio.c
programs/util.c
programs/util.h

index 9d3054b1c3960ebbecc372e3728b9e2932215bbd..b29295586dc4aa1c1ef3e23449c5921afd2444bc 100644 (file)
@@ -1527,26 +1527,6 @@ FIO_compressZstdFrame(FIO_ctx_t* const fCtx,
     return compressedfilesize;
 }
 
-char* human_size(long size, char* str) {
-       if (size > 1125899906842624L) {
-               snprintf(str, 7, "%.1fP", (float)size / 1125899906842624L);
-       } else if (size > 1099511627776L) {
-               snprintf(str, 7, "%.1fT", (float)size / 1099511627776L);
-       } else if (size > 1073741824L) {
-               snprintf(str, 7, "%.1fG", (float)size / 1073741824L);
-       } else if (size > 1048576L) {
-               snprintf(str, 7, "%.1fM", (float)size / 1048576L);
-       } else if (size > 1024) {
-               snprintf(str, 7, "%.1fK", (float)size / 1024);
-       } else if (size >= 0) {
-               snprintf(str, 7, "%dB", size);
-       } else {
-               str[0] = '\0';
-       }
-
-       return str;
-}
-
 /*! FIO_compressFilename_internal() :
  *  same as FIO_compressFilename_extRess(), with `ress.desFile` already opened.
  *  @return : 0 : compression completed correctly,
index 8d190c62c46aa19dc6f5e5149d3118be80861aeb..d942d37324e62b5422f5749cd5893252441646de 100644 (file)
@@ -121,6 +121,27 @@ int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg,
 *  Functions
 ***************************************/
 
+char* human_size(long size, char* str) {
+       if (size > 1125899906842624L) {
+               snprintf(str, 7, "%.1fP", (float)size / 1125899906842624L);
+       } else if (size > 1099511627776L) {
+               snprintf(str, 7, "%.1fT", (float)size / 1099511627776L);
+       } else if (size > 1073741824L) {
+               snprintf(str, 7, "%.1fG", (float)size / 1073741824L);
+       } else if (size > 1048576L) {
+               snprintf(str, 7, "%.1fM", (float)size / 1048576L);
+       } else if (size > 1024) {
+               snprintf(str, 7, "%.1fK", (float)size / 1024);
+       } else if (size >= 0) {
+               snprintf(str, 7, "%dB", size);
+       } else {
+               str[0] = '\0';
+       }
+
+       return str;
+}
+
+
 int UTIL_stat(const char* filename, stat_t* statbuf)
 {
 #if defined(_MSC_VER)
index 24cce44804dd845e952ca4bacae3e8fa212debcd..415b01f1b244340bc2300456c79fbef5dd91634d 100644 (file)
@@ -122,6 +122,8 @@ int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg, const
 #define STRDUP(s) strdup(s)
 #endif
 
+char* human_size(long size, char* str);
+
 /**
  * Calls platform's equivalent of stat() on filename and writes info to statbuf.
  * Returns success (1) or failure (0).