-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
212 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
iCloudDownlader.xcodeproj/xcuserdata/lucas.xcuserdatad/xcschemes/iCloudDownlader.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "0940" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A0CF17842144B66500D1DDCC" | ||
BuildableName = "iCloudDownlader" | ||
BlueprintName = "iCloudDownlader" | ||
ReferencedContainer = "container:iCloudDownlader.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A0CF17842144B66500D1DDCC" | ||
BuildableName = "iCloudDownlader" | ||
BlueprintName = "iCloudDownlader" | ||
ReferencedContainer = "container:iCloudDownlader.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A0CF17842144B66500D1DDCC" | ||
BuildableName = "iCloudDownlader" | ||
BlueprintName = "iCloudDownlader" | ||
ReferencedContainer = "container:iCloudDownlader.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
<CommandLineArguments> | ||
<CommandLineArgument | ||
argument = "-A" | ||
isEnabled = "NO"> | ||
</CommandLineArgument> | ||
</CommandLineArguments> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "A0CF17842144B66500D1DDCC" | ||
BuildableName = "iCloudDownlader" | ||
BlueprintName = "iCloudDownlader" | ||
ReferencedContainer = "container:iCloudDownlader.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// ConsoleIO.swift | ||
// iCloudDownlader | ||
// | ||
// Created by Lucas Tarasconi on 09/09/2018. | ||
// Copyright © 2018 Lucas Tarasconi. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
enum OutputType { | ||
case error | ||
case standard | ||
case warning | ||
} | ||
|
||
class ConsoleIO { | ||
func writeMessage(_ message: String, to: OutputType = .standard) { | ||
switch to { | ||
case .standard: | ||
print("\(message)") | ||
case .warning: | ||
print("Warning: \(message)") | ||
case .error: | ||
fputs("Error: \(message)\n", stderr) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// Downloader.swift | ||
// iCloudDownlader | ||
// | ||
// Created by Lucas Tarasconi on 09/09/2018. | ||
// Copyright © 2018 Lucas Tarasconi. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
let fm = FileManager.default | ||
let path = fm.currentDirectoryPath | ||
|
||
class Downloader { | ||
let consoleIO = ConsoleIO() | ||
|
||
func fetchFile(fileUrl : URL) { | ||
if fm.isUbiquitousItem(at: fileUrl){ | ||
do { | ||
try fm.startDownloadingUbiquitousItem(at: fileUrl) | ||
consoleIO.writeMessage("Info : \(fileUrl.lastPathComponent) is downloading") | ||
} catch { | ||
consoleIO.writeMessage("Can't download \(fm.displayName(atPath: fileUrl.lastPathComponent))", to: .error) | ||
} | ||
} | ||
else { | ||
consoleIO.writeMessage("\(fm.displayName(atPath: fileUrl.lastPathComponent)) is already download", to: .warning) | ||
} | ||
} | ||
|
||
func downloadFile() { | ||
let file = CommandLine.arguments[1] | ||
let fileUrl = NSURL.fileURL(withPath: file) | ||
fetchFile(fileUrl: fileUrl) | ||
|
||
} | ||
|
||
func downloadFolder() { | ||
do { | ||
let items = try fm.contentsOfDirectory(atPath: path) | ||
|
||
for item in items { | ||
let itemUrl = NSURL.fileURL(withPath: item) | ||
fetchFile(fileUrl: itemUrl) | ||
} | ||
} catch { | ||
consoleIO.writeMessage("Can't acces the folder", to: .error) | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters