]> granicus.if.org Git - transmission/commitdiff
Add option "--unsorted" for transmission-show
authortakiz <tacidd@gmail.com>
Mon, 19 Nov 2018 10:35:32 +0000 (15:35 +0500)
committertakiz <tacidd@gmail.com>
Mon, 19 Nov 2018 10:35:32 +0000 (15:35 +0500)
utils/show.c

index 78bf661d7717e6cfa75e2be47ff9becfc48342c4..1b667bf1745d6774c2e855a0d3025ef6ed845887 100644 (file)
@@ -32,6 +32,7 @@ static tr_option options[] =
 {
     { 'm', "magnet", "Give a magnet link for the specified torrent", "m", 0, NULL },
     { 's', "scrape", "Ask the torrent's trackers how many peers are in the torrent's swarm", "s", 0, NULL },
+    { 'u', "unsorted", "Do not sort files by name", "u", 0, NULL },
     { 'V', "version", "Show version number and exit", "V", 0, NULL },
     { 0, NULL, NULL, NULL, 0, NULL }
 };
@@ -43,6 +44,7 @@ static char const* getUsage(void)
 
 static bool magnetFlag = false;
 static bool scrapeFlag = false;
+static bool unsorted = false;
 static bool showVersion = false;
 char const* filename = NULL;
 
@@ -63,6 +65,10 @@ static int parseCommandLine(int argc, char const* const* argv)
             scrapeFlag = true;
             break;
 
+        case 'u':
+            unsorted = true;
+            break;
+
         case 'V':
             showVersion = true;
             break;
@@ -188,8 +194,11 @@ static void showInfo(tr_info const* inf)
     {
         files[i] = &inf->files[i];
     }
-
-    qsort(files, inf->fileCount, sizeof(tr_file*), compare_files_by_name);
+    
+    if (!unsorted)
+    {
+        qsort(files, inf->fileCount, sizeof(tr_file*), compare_files_by_name);
+    }
 
     for (unsigned int i = 0; i < inf->fileCount; ++i)
     {