Skip to content

Commit

Permalink
Try all mountedLocalVolumePaths in addition to mountedRemovableMedia …
Browse files Browse the repository at this point in the history
…as iPods (and/or iPhones). If you're using i.e. iExplorer to mount your iPhone, this will now work out of the box.
  • Loading branch information
znek committed Mar 25, 2015
1 parent 36ce11f commit ec26ffd
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 13 deletions.
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ iTunesFS_OBJC_FILES += \
\
StreamReader.m \
NSString+Extensions.m \
NSMutableArray+Extensions.m \
NSURL+Extensions.m \
NSData+ZlibDecompression.m \

Expand Down
6 changes: 3 additions & 3 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>iTunesFS version 1.3.4, Copyright 2007-2015 Mulle kybernetiK.</string>
<string>iTunesFS version 1.3.5, Copyright 2007-2015 Mulle kybernetiK.</string>
<key>CFBundleIconFile</key>
<string>iTunesFS</string>
<key>CFBundleIdentifier</key>
Expand All @@ -19,11 +19,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.4</string>
<string>1.3.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.4</string>
<string>1.3.5</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSUIElement</key>
Expand Down
45 changes: 45 additions & 0 deletions NSMutableArray+Extensions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright (c) 2015, Marcus Müller <znek@mulle-kybernetik.com>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of Mulle kybernetiK nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __iTunesFS_NSMutableArray_Extensions_H
#define __iTunesFS_NSMutableArray_Extensions_H

#import <Foundation/Foundation.h>

@interface NSMutableArray (iTunesFSExtensions)

- (void)addObjectIfAbsent:(id)_obj;
- (void)addObjectsFromArrayIfAbsent:(NSArray *)_objects;

@end

#endif /* __iTunesFS_NSMutableArray_Extensions_H */
50 changes: 50 additions & 0 deletions NSMutableArray+Extensions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright (c) 2015, Marcus Müller <znek@mulle-kybernetik.com>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of Mulle kybernetiK nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

#import "common.h"
#import "NSMutableArray+Extensions.h"

@implementation NSMutableArray (iTunesFSExtensions)

- (void)addObjectIfAbsent:(id)_obj {
if (_obj && ![self containsObject:_obj])
[self addObject:_obj];
}

- (void)addObjectsFromArrayIfAbsent:(NSArray *)_objects {
NSUInteger i, count = [_objects count];
for (i = 0; i < count; i++) {
[self addObjectIfAbsent:[_objects objectAtIndex:i]];
}
}

@end /* NSMutableArray (iTunesFSExtensions) */
2 changes: 1 addition & 1 deletion Version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
MAJOR_VERSION=1
MINOR_VERSION=3
SUBMINOR_VERSION=4
SUBMINOR_VERSION=5
6 changes: 6 additions & 0 deletions iTunesFS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
7F74EF2D0B4C1BEC00CFA0C0 /* iTunesFileSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F74EF2C0B4C1BEC00CFA0C0 /* iTunesFileSystem.m */; };
AD0272621AC32AAC00B63416 /* NSMutableArray+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = AD0272611AC32AAC00B63416 /* NSMutableArray+Extensions.m */; };
AD0667BE0D870A7A0095EDEF /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD0667BD0D870A7A0095EDEF /* Cocoa.framework */; };
AD0667DF0D870B520095EDEF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AD0667DE0D870B520095EDEF /* main.m */; };
AD0A21B712F44D3500339646 /* FUSEOFSAppController.m in Sources */ = {isa = PBXBuildFile; fileRef = AD0A21B612F44D3500339646 /* FUSEOFSAppController.m */; };
Expand Down Expand Up @@ -48,6 +49,8 @@
7F74EF2B0B4C1BEC00CFA0C0 /* iTunesFileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = iTunesFileSystem.h; sourceTree = "<group>"; tabWidth = 2; usesTabs = 0; };
7F74EF2C0B4C1BEC00CFA0C0 /* iTunesFileSystem.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = iTunesFileSystem.m; sourceTree = "<group>"; tabWidth = 2; usesTabs = 0; };
AD0073DC12F0131500E05C0D /* ChangeLog */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 8; lastKnownFileType = text; lineEnding = 0; path = ChangeLog; sourceTree = "<group>"; tabWidth = 8; usesTabs = 1; wrapsLines = 0; };
AD02725F1AC329D600B63416 /* NSMutableArray+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+Extensions.h"; sourceTree = "<group>"; };
AD0272611AC32AAC00B63416 /* NSMutableArray+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableArray+Extensions.m"; sourceTree = "<group>"; };
AD0667BD0D870A7A0095EDEF /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = ../../../System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
AD0667DE0D870B520095EDEF /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; tabWidth = 2; usesTabs = 0; };
AD0A21B512F44D3500339646 /* FUSEOFSAppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = FUSEOFSAppController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -304,6 +307,8 @@
ADB59B741033716B002A2998 /* StreamReader.m */,
ADBDABA70C02FF10004CF795 /* NSString+Extensions.h */,
ADBDABA80C02FF10004CF795 /* NSString+Extensions.m */,
AD02725F1AC329D600B63416 /* NSMutableArray+Extensions.h */,
AD0272611AC32AAC00B63416 /* NSMutableArray+Extensions.m */,
AD2186D30C0D4805008FB568 /* NSURL+Extensions.h */,
AD2186D40C0D4805008FB568 /* NSURL+Extensions.m */,
ADF74EC0102F2AF300FED3EA /* NSData+ZlibDecompression.h */,
Expand Down Expand Up @@ -418,6 +423,7 @@
buildActionMask = 2147483647;
files = (
7F74EF2D0B4C1BEC00CFA0C0 /* iTunesFileSystem.m in Sources */,
AD0272621AC32AAC00B63416 /* NSMutableArray+Extensions.m in Sources */,
AD37A2970C01C87E00DF1291 /* iTunesLibrary.m in Sources */,
ADBDABA90C02FF10004CF795 /* NSString+Extensions.m in Sources */,
AD15A2190C03208500345C9E /* iTunesPlaylist.m in Sources */,
Expand Down
16 changes: 7 additions & 9 deletions iTunesFileSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#import "NSObject+FUSEOFS.h"
#import "FUSEOFSMemoryContainer.h"
#import "iTunesFormatFile.h"
#import "NSMutableArray+Extensions.h"

@interface iTunesFileSystem (Private)
- (void)addLibrary:(iTunesLibrary *)_lib;
Expand Down Expand Up @@ -69,7 +70,6 @@ @implementation iTunesFileSystem

static NSString *fsIconPath = nil;
static NSArray *fakeVolumePaths = nil;
static NSString *iPhoneDiskPath = @"/Volumes/iPhoneDisk";
static NSString *playlistsTrackFormatFileName = @"PlaylistsTrackFormat.txt";
static NSString *albumsTrackFormatFileName = @"AlbumsTrackFormat.txt";

Expand Down Expand Up @@ -126,17 +126,15 @@ - (void)willMount {
[lib release];
}
if (!ignoreIPods) {
NSWorkspace *ws = [NSWorkspace sharedWorkspace];

// add mounted iPods
NSArray *volPaths = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
NSMutableArray *volPaths =
[NSMutableArray arrayWithArray:[ws mountedLocalVolumePaths]];
[volPaths addObjectsFromArrayIfAbsent:[ws mountedRemovableMedia]];

if (fakeVolumePaths)
volPaths = [volPaths arrayByAddingObjectsFromArray:fakeVolumePaths];

// workaround for Finder's inability to treat FUSE filesystems as
// removable media
if (![volPaths containsObject:iPhoneDiskPath]) {
volPaths = [volPaths arrayByAddingObject:iPhoneDiskPath];
}
[volPaths addObjectsFromArrayIfAbsent:fakeVolumePaths];

lib = nil;
unsigned count = [volPaths count];
Expand Down

0 comments on commit ec26ffd

Please sign in to comment.