]> git.sesse.net Git - vlc/commitdiff
macosx: add file size column to playlist table (close #9497)
authorFelix Paul Kühne <fkuehne@videolan.org>
Sun, 2 Feb 2014 19:30:27 +0000 (20:30 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sun, 2 Feb 2014 21:49:03 +0000 (22:49 +0100)
modules/gui/macosx/MainMenu.m
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index 0f4b0fab2cdb7e1cfb66bf84c0edb002d24e5d19..301d0e72b8827ea0fd2ca2b5b39466e7b7e903df 100644 (file)
@@ -76,11 +76,13 @@ static VLCMainMenu *_o_sharedInstance = nil;
                       _NS("Date"),          DATE_COLUMN,
                       _NS("Language"),      LANGUAGE_COLUMN,
                       _NS("URI"),           URI_COLUMN,
+                      _NS("File Size"),     FILESIZE_COLUMN,
                       nil];
         // this array also assigns tags (index) to type of menu item
         o_ptc_menuorder = [[NSArray alloc] initWithObjects: TRACKNUM_COLUMN, TITLE_COLUMN,
                            ARTIST_COLUMN, DURATION_COLUMN, GENRE_COLUMN, ALBUM_COLUMN,
-                           DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN, nil];
+                           DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN,
+                           FILESIZE_COLUMN,nil];
     }
 
     return _o_sharedInstance;
index 7ffc0609365bf08bff07bbafe1254b47187818cc..900ab49c9905911795fb975cf57cf5e5f87da1ef 100644 (file)
@@ -36,6 +36,7 @@
 #define DATE_COLUMN @"date"
 #define LANGUAGE_COLUMN @"language"
 #define URI_COLUMN @"uri"
+#define FILESIZE_COLUMN @"file-size"
 
 /*****************************************************************************
  * VLCPlaylistView interface
index 270b238974209ac5fb34a0d3e985b635809ebc46..d2b636c84e17b757263f23101740396467e4b25f 100644 (file)
             free(psz_value);
         }
     }
+    else if ([o_identifier isEqualToString:FILESIZE_COLUMN]) {
+        psz_value = input_item_GetURI(p_item->p_input);
+        o_value = @"";
+        if (psz_value) {
+            NSURL *url = [NSURL URLWithString:[NSString stringWithUTF8String:psz_value]];
+            if ([url isFileURL]) {
+                NSFileManager *fileManager = [NSFileManager defaultManager];
+                if ([fileManager fileExistsAtPath:[url path]]) {
+                    NSError *error;
+                    NSDictionary *attributes = [fileManager attributesOfItemAtPath:[url path] error:&error];
+                    o_value = [NSByteCountFormatter stringFromByteCount:[attributes fileSize] countStyle:NSByteCountFormatterCountStyleDecimal];
+                }
+            }
+            free(psz_value);
+        }
+    }
     else if ([o_identifier isEqualToString:@"status"]) {
         if (input_item_HasErrorWhenReading(p_item->p_input)) {
             o_value = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertCautionIcon)];