Commits

Anonymous committed c76ba1c

Added file tracking to file playlist entries using filerefs.

  • Participants
  • Parent commits 5fa55ae

Comments (0)

Files changed (4)

Cog.xcodeproj/project.pbxproj

 		1791005F0CB44D6D0070BC5C /* Cog.scriptTerminology in Resources */ = {isa = PBXBuildFile; fileRef = 1791005D0CB44D6D0070BC5C /* Cog.scriptTerminology */; };
 		1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 1791FF8E0CB43A2C0070BC5C /* MediaKeysApplication.m */; };
 		179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 179790DF0C087AB7001D6996 /* OpenURLPanel.m */; };
+		17A140E90D88B954004852F9 /* FilePlaylistEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = 17A140E80D88B954004852F9 /* FilePlaylistEntry.m */; };
 		17A8F6370D6A7B0F0095DA13 /* RepeatTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = 17A8F6360D6A7B0F0095DA13 /* RepeatTransformers.m */; };
 		17A8F6850D6A7FCA0095DA13 /* repeat_all.png in Resources */ = {isa = PBXBuildFile; fileRef = 17A8F6820D6A7FCA0095DA13 /* repeat_all.png */; };
 		17A8F6860D6A7FCA0095DA13 /* repeat_none.png in Resources */ = {isa = PBXBuildFile; fileRef = 17A8F6830D6A7FCA0095DA13 /* repeat_none.png */; };
 		1791FF8E0CB43A2C0070BC5C /* MediaKeysApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MediaKeysApplication.m; sourceTree = "<group>"; };
 		179790DE0C087AB7001D6996 /* OpenURLPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OpenURLPanel.h; sourceTree = "<group>"; };
 		179790DF0C087AB7001D6996 /* OpenURLPanel.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = OpenURLPanel.m; sourceTree = "<group>"; };
+		17A140E70D88B954004852F9 /* FilePlaylistEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilePlaylistEntry.h; sourceTree = "<group>"; };
+		17A140E80D88B954004852F9 /* FilePlaylistEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilePlaylistEntry.m; sourceTree = "<group>"; };
 		17A8F6350D6A7B0F0095DA13 /* RepeatTransformers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RepeatTransformers.h; sourceTree = "<group>"; };
 		17A8F6360D6A7B0F0095DA13 /* RepeatTransformers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RepeatTransformers.m; sourceTree = "<group>"; };
 		17A8F6820D6A7FCA0095DA13 /* repeat_all.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_all.png; path = Images/repeat_all.png; sourceTree = "<group>"; };
 				17B7DD7C0D7CD10D00320E70 /* BlankZeroFormatter.m */,
 				17249F0D0D82E17700F33392 /* ToggleQueueTitleTransformer.h */,
 				17249F0E0D82E17700F33392 /* ToggleQueueTitleTransformer.m */,
+				17A140E70D88B954004852F9 /* FilePlaylistEntry.h */,
+				17A140E80D88B954004852F9 /* FilePlaylistEntry.m */,
 			);
 			path = Playlist;
 			sourceTree = "<group>";
 				170B55940D6E5E7B006B9E92 /* StatusImageTransformer.m in Sources */,
 				17B7DD7D0D7CD10D00320E70 /* BlankZeroFormatter.m in Sources */,
 				17249F0F0D82E17700F33392 /* ToggleQueueTitleTransformer.m in Sources */,
+				17A140E90D88B954004852F9 /* FilePlaylistEntry.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Playlist/FilePlaylistEntry.h

+//
+//  FilePlaylistEntry.h
+//  Cog
+//
+//  Created by Vincent Spader on 3/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+#import "PlaylistEntry.h"
+
+
+@interface FilePlaylistEntry : PlaylistEntry {
+	FSRef fileRef;
+}
+
+@end

Playlist/FilePlaylistEntry.m

+//
+//  FilePlaylistEntry.m
+//  Cog
+//
+//  Created by Vincent Spader on 3/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "FilePlaylistEntry.h"
+
+
+@implementation FilePlaylistEntry
+
+- (void)setURL:(NSURL *)url
+{
+	FSPathMakeRef((UInt8 *)[[url path] fileSystemRepresentation], &fileRef, NULL);
+}
+
+- (NSURL *)URL
+{
+    UInt8 path[PATH_MAX];
+
+	OSStatus status = FSRefMakePath(&fileRef, (UInt8*)path, sizeof(path)); 
+	if (status != noErr) 
+		return nil;
+		
+    return [NSURL fileURLWithPath: [NSString stringWithUTF8String:(const char *)path]]; 
+}
+
+@end

Playlist/PlaylistLoader.m

 #import "PlaylistLoader.h"
 #import "PlaylistController.h"
 #import "PlaylistEntry.h"
+#import "FilePlaylistEntry.h"
 #import "AppController.h"
 
 #import "NSFileHandle+CreateFile.h"
 	NSMutableArray *entries = [NSMutableArray arrayWithCapacity:[validURLs count]];
 	for (i = 0; i < [validURLs count]; i++)
 	{
-		PlaylistEntry *pe = [[PlaylistEntry alloc] init];
 		NSURL *url = [validURLs objectAtIndex:i];
+		
+		PlaylistEntry *pe;
+		if ([url isFileURL]) 
+			pe = [[FilePlaylistEntry alloc] init];
+		else
+			pe = [[PlaylistEntry alloc] init];
 
 		pe.URL = url;
 		pe.index = index+i;