Revision: 3986
http://skim-app.svn.sourceforge.net/skim-app/?rev=3986&view=rev
Author: hofman
Date: 2008-06-07 07:43:51 -0700 (Sat, 07 Jun 2008)
Log Message:
-----------
simplify completing path in skimnotes tool
Modified Paths:
--------------
trunk/skimnotes.m
Modified: trunk/skimnotes.m
===================================================================
--- trunk/skimnotes.m 2008-06-07 14:35:15 UTC (rev 3985)
+++ trunk/skimnotes.m 2008-06-07 14:43:51 UTC (rev 3986)
@@ -50,27 +50,25 @@
return SKNActionUnknown;
}
-static inline NSString *SKNNormalizedPath(NSString *path, NSString *basePath) {
+static inline NSString *SKNNormalizedPath(NSString *path) {
if ([path isEqualToString:@"-"] == NO) {
- unichar ch = [path length] ? [path characterAtIndex:0] : 0;
- if (basePath && ch != '/' && ch != '~')
- path = [basePath stringByAppendingPathComponent:path];
+ if ([path isAbsolutePath] == NO) {
+ NSString *basePath = [[NSFileManager defaultManager]
currentDirectoryPath];
+ if (basePath)
+ path = [basePath stringByAppendingPathComponent:path];
+ }
path = [path stringByStandardizingPath];
}
return path;
}
-static inline void SKNWriteUsageAndVersion() {
- fprintf (stderr, "%s\n%s\n", usageStr, versionStr);
-}
-
int main (int argc, const char * argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *args = [[NSProcessInfo processInfo] arguments];
if (argc < 2) {
- SKNWriteUsageAndVersion();
+ fprintf (stderr, "%s\n%s\n", usageStr, versionStr);
[pool release];
exit (1);
}
@@ -134,7 +132,7 @@
} else {
if (argc < 3) {
- SKNWriteUsageAndVersion();
+ fprintf (stderr, "%s\n%s\n", usageStr, versionStr);
[pool release];
exit (1);
}
@@ -145,7 +143,7 @@
if ([[args objectAtIndex:2] isEqualToString:@"-format"]) {
if (argc < 5) {
- SKNWriteUsageAndVersion();
+ fprintf (stderr, "%s\n%s\n", usageStr, versionStr);
[pool release];
exit (1);
}
@@ -160,9 +158,8 @@
}
NSFileManager *fm = [NSFileManager defaultManager];
- NSString *currentDir = [fm currentDirectoryPath];
- NSString *pdfPath = SKNNormalizedPath([args objectAtIndex:offset],
currentDir);
- NSString *notesPath = argc < offset + 2 ? nil :
SKNNormalizedPath([args objectAtIndex:offset + 1], currentDir);
+ NSString *pdfPath = SKNNormalizedPath([args objectAtIndex:offset]);
+ NSString *notesPath = argc < offset + 2 ? nil :
SKNNormalizedPath([args objectAtIndex:offset + 1]);
BOOL isDir = NO;
NSError *error = nil;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit