Skip to content

Commit

Permalink
Capitalisation consistency for comments across the project
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinbjornt committed Mar 7, 2018
1 parent dac8fd9 commit 06b95c0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 54 deletions.
2 changes: 1 addition & 1 deletion source/Common.h
Expand Up @@ -54,7 +54,7 @@

#define VALUES_KEYPATH(X) [NSString stringWithFormat:@"values.%@", (X)]

// let's make things a bit less verbose
// Let's make things a bit less verbose
#define FILEMGR [NSFileManager defaultManager]
#define DEFAULTS [NSUserDefaults standardUserDefaults]
#define WORKSPACE [NSWorkspace sharedWorkspace]
32 changes: 16 additions & 16 deletions source/InfoPanelController.m
Expand Up @@ -75,7 +75,7 @@ - (void)setItem:(NSDictionary *)itemDict {
BOOL isFileOrFolder = [type isEqualToString:@"File"] || [type isEqualToString:@"Directory"];
BOOL isIPSocket = [type isEqualToString:@"IP Socket"];

// name
// Name
NSString *name = isFileOrFolder ? [itemDict[@"name"] lastPathComponent] : itemDict[@"name"];
if (name == nil || [name isEqualToString:@""]) {
name = [NSString stringWithFormat:@"Unnamed %@", type];
Expand All @@ -86,7 +86,7 @@ - (void)setItem:(NSDictionary *)itemDict {
[self.window setTitle:name];
[self.nameTextField setStringValue:name];

// path
// Path
NSString *path = @"";
if (isFileOrFolder || isProcess) {
NSString *p = [itemDict[@"type"] isEqualToString:@"Process"] ? itemDict[@"bundlepath"] : itemDict[@"name"];
Expand All @@ -95,7 +95,7 @@ - (void)setItem:(NSDictionary *)itemDict {
self.path = path;
[self.pathTextField setStringValue:path];

// icon
// Icon
NSImage *img = isFileOrFolder ? [WORKSPACE iconForFile:path] : [itemDict[@"image"] copy];
[img setSize:NSMakeSize(48,48)];
[self.iconView setImage:img];
Expand All @@ -106,7 +106,7 @@ - (void)setItem:(NSDictionary *)itemDict {
}
[self.sizeTextField setStringValue:sizeStr];

// type
// Type
NSString *typeStr = type;
if (isProcess) {
register struct passwd *pw;
Expand All @@ -119,7 +119,7 @@ - (void)setItem:(NSDictionary *)itemDict {
}
[self.itemTypeTextField setStringValue:typeStr];

// owned by
// Owned by
if (isProcess) {
NSString *pidStr = [NSString stringWithFormat:@"PID: %@", itemDict[@"pid"]];
[self.usedByTextField setStringValue:@""];
Expand All @@ -129,13 +129,13 @@ - (void)setItem:(NSDictionary *)itemDict {
[self.usedByTextField setStringValue:ownedByStr];
}

// access mode
// Access mode
NSString *access = [self accessModeDescriptionForMode:itemDict[@"accessmode"]];
if (access == nil) {
if (itemDict[@"fd"] == nil) {
access = @"";
} else {
// try to scan int to see if we have a file descriptor number
// Try to scan int to see if we have a file descriptor number
int num;
BOOL isInteger = [[NSScanner scannerWithString:itemDict[@"fd"]] scanInt:&num];
if (isInteger) {
Expand All @@ -147,7 +147,7 @@ - (void)setItem:(NSDictionary *)itemDict {
}
[self.accessModeTextField setStringValue:access];

// the other fields
// The other fields
if ((!isFileOrFolder && (!isProcess || (isProcess && itemDict[@"bundlepath"] == nil))) ||
(isFileOrFolder && ![FILEMGR fileExistsAtPath:itemDict[@"name"]])) {
[self.filetypeTextField setStringValue:@""];
Expand All @@ -164,7 +164,7 @@ - (void)setItem:(NSDictionary *)itemDict {
[self.permissionsTextField setStringValue:permString];
}

// buttons
// Buttons
BOOL workablePath = isFileOrFolder || (isProcess && [FILEMGR fileExistsAtPath:path]);
[self.showInFinderButton setEnabled:workablePath];
[self.getFinderInfoButton setEnabled:workablePath];
Expand Down Expand Up @@ -199,12 +199,12 @@ - (NSString *)permissionsStringForPath:(NSString *)filePath {
[result appendString:@"-"];
}

// loop through POSIX permissions, starting at user, then group, then other.
// Loop through POSIX permissions, starting at user, then group, then other.
for (int i = 2; i >= 0; i--) {
// this creates an index from 0 to 7
// This creates an index from 0 to 7
unsigned long thisPart = (perms >> (i * 3)) & 0x7;

// we look up this index in our permissions array and append it.
// We look up this index in our permissions array and append it.
[result appendString:[permsArray objectAtIndex:thisPart]];
}

Expand Down Expand Up @@ -240,7 +240,7 @@ - (NSString *)fileInfoForPath:(NSString *)filePath {
if (![FILEMGR fileExistsAtPath:filePath]) {
return @"";
}
// run file command and get output
// Run 'file' command and get output
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/file"];
[task setArguments:@[@"-b", filePath]];
Expand All @@ -264,7 +264,7 @@ - (NSString *)fileSizeStringForPath:(NSString *)filePath {
return @"";
}

UInt64 size = [self fileOrFolderSize:filePath];
UInt64 size = [self fileSizeAtPath:filePath];
NSString *humanSize = [self sizeAsHumanReadable:size];

NSString *finalString = humanSize;
Expand Down Expand Up @@ -344,8 +344,8 @@ - (BOOL)runAppleScript:(NSString *)scriptSource {
}
}

- (UInt64)fileOrFolderSize:(NSString *)path {
// returns size 0 for directories
- (UInt64)fileSizeAtPath:(NSString *)path {
// Return size 0 for directories
BOOL isDir;
if (path == nil || ![FILEMGR fileExistsAtPath:path isDirectory:&isDir] || isDir) {
return 0;
Expand Down

0 comments on commit 06b95c0

Please sign in to comment.