Skip to content

Commit

Permalink
Update the source code
Browse files Browse the repository at this point in the history
  • Loading branch information
yamadapc committed Jan 13, 2016
1 parent e01b0f4 commit fe3b72c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
4 changes: 4 additions & 0 deletions iBooks Export.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@
667EACAB1B51F68800E09272 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0720;
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0640;
ORGANIZATIONNAME = pty;
TargetAttributes = {
Expand Down Expand Up @@ -400,6 +402,7 @@
667EACD11B51F68800E09272 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
667EACD21B51F68800E09272 /* Build configuration list for PBXNativeTarget "iBooks ExportTests" */ = {
isa = XCConfigurationList;
Expand All @@ -408,6 +411,7 @@
667EACD41B51F68800E09272 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
18 changes: 9 additions & 9 deletions iBooks Export/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<scenes>
<!--Application-->
Expand Down Expand Up @@ -650,7 +650,7 @@
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<window key="window" title="iBooks Export" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="668" height="323"/>
Expand All @@ -675,11 +675,11 @@
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xeP-jo-oUq">
<rect key="frame" x="0.0" y="34" width="668" height="236"/>
<clipView key="contentView" id="4VE-FI-JKk">
<rect key="frame" x="1" y="17" width="238" height="117"/>
<rect key="frame" x="1" y="0.0" width="666" height="235"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" headerView="Drj-2P-DcV" id="M2g-Jr-8Ok">
<rect key="frame" x="0.0" y="0.0" width="718" height="19"/>
<rect key="frame" x="0.0" y="0.0" width="666" height="212"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -729,16 +729,16 @@
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.019155557487833565" horizontal="YES" id="ihM-xV-aUc">
<rect key="frame" x="1" y="119" width="223" height="15"/>
<scroller key="horizontalScroller" verticalHuggingPriority="750" doubleValue="0.019155557487833565" horizontal="YES" id="ihM-xV-aUc">
<rect key="frame" x="1" y="219" width="666" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="ZSO-Su-8VL">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="Drj-2P-DcV">
<rect key="frame" x="0.0" y="0.0" width="238" height="17"/>
<rect key="frame" x="0.0" y="0.0" width="666" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
Expand All @@ -747,7 +747,7 @@
</progressIndicator>
<button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Bj8-I3-ZDG">
<rect key="frame" x="572" y="0.0" width="82" height="32"/>
<buttonCell key="cell" type="push" title="Extract" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="X38-sW-YnJ">
<buttonCell key="cell" type="push" title="Export" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="X38-sW-YnJ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
Expand Down
35 changes: 26 additions & 9 deletions iBooks Export/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,38 @@ class ViewController: NSViewController, NSTableViewDataSource {
let filemanager = NSFileManager()
var error: NSError?

var isDir = UnsafeMutablePointer<ObjCBool>.alloc(1)
var exists = filemanager.fileExistsAtPath(exportDir!, isDirectory: isDir)
if exists && isDir.memory {
filemanager.createDirectoryAtPath(exportDir!, withIntermediateDirectories: false, attributes: nil, error: &error)
let isDir = UnsafeMutablePointer<ObjCBool>.alloc(1)
let exists = filemanager.fileExistsAtPath(exportDir!, isDirectory: isDir)
if !exists && isDir.memory {
do {
try filemanager.createDirectoryAtPath(exportDir!, withIntermediateDirectories: false, attributes: nil)
} catch let error1 as NSError {
error = error1
} catch {
fatalError()
}
}

if error != nil {
println(error)
print(error)
}

for book in self.books {
if let targetPath = self.targetPath(book) {
filemanager.copyItemAtPath(book.path, toPath: exportDir! + "/" + targetPath, error: &error)
if filemanager.fileExistsAtPath(exportDir! + "/" + targetPath) {
self.progressIndicator.incrementBy(1)
continue
}

do {
try filemanager.copyItemAtPath(book.path, toPath: exportDir! + "/" + targetPath)
} catch let error1 as NSError {
error = error1
} catch {
fatalError()
}
if error != nil {
println(error)
print(error)
}
}

Expand Down Expand Up @@ -101,7 +118,7 @@ class ViewController: NSViewController, NSTableViewDataSource {
case "displayName":
return book.displayName
case "path":
return book.path.lastPathComponent
return (book.path as NSString).lastPathComponent
default:
return nil
}
Expand All @@ -124,7 +141,7 @@ class ViewController: NSViewController, NSTableViewDataSource {
private func targetPath(book: Book) -> String? {
if book.displayName != "" {
if let itemName = book.itemName {
return itemName + "." + book.path.pathExtension
return itemName + "." + (book.path as NSString).pathExtension
}
return nil
}
Expand Down

0 comments on commit fe3b72c

Please sign in to comment.