Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ololx committed Sep 17, 2021
2 parents a7a6c2f + 0c7bb5f commit 830ddaa
Show file tree
Hide file tree
Showing 33 changed files with 274 additions and 186 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
Localizable.strings
quick-symlink

Created by Alexander A. Kropotin on 15/07/2021.
Copyright © 2021 Alexander A. Kropotin. All rights reserved.
*/
/*
Localizable.strings
quick-symlink
Created by Alexander A. Kropotin on 15/07/2021.
Copyright © 2021 Alexander A. Kropotin. All rights reserved.
*/

/* Class = "NSMenuItem"; */
"SOFT_LINK_ACTIONS_EXTENTION_NAME" = "Действия с симлинками";
Expand All @@ -29,3 +29,4 @@

/* Class = "NSMenuItem"; */
"CREATE_LINK_ACTION_NAME" = "Создать ссылку";

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

- Refactor application.

## [0.9.0] - 2021-09-17

### Changed

- Change the extention boubdle name from `quick-symlink-extention to `symlink actions`.
- Change the module name `quick-symlink-extention to `soft-link-actions-name`.

## [0.8.1] - 2021-09-13

### Fixed
Expand Down
49 changes: 49 additions & 0 deletions commons/defaults/QuickSymlinkDefaults.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// PathTypeDefaults.swift
// quick-symlink
//
// Created by Alexander A. Kropotin on 17/09/2021.
// Copyright © 2021 Alexander A. Kropotin. All rights reserved.
//

import Foundation

public struct QuickSymlinkDefaults<T> {
var key: String
var defaultValue: T
}

public extension QuickSymlinkDefaults {

func get() -> T {
guard let valueUntyped = UserDefaults.init(suiteName: "org.ololx.quick-symlink")?.object(forKey: self.key) else {
return self.defaultValue;
}

guard let value = valueUntyped as? T else {
return self.defaultValue;
}

return value;
}

func set(_ value: T) {
UserDefaults.init(suiteName: "org.ololx.quick-symlink")?.set(value, forKey: self.key);
}
}

public enum QuickSymlinkSettings {

static var relativePath: Bool {
get {
return pathTypeStrategyDefaults.get();

}
set {
pathTypeStrategyDefaults.set(newValue);

}
}

private static var pathTypeStrategyDefaults = QuickSymlinkDefaults(key: "relative-path-strategy", defaultValue: false);
}
14 changes: 12 additions & 2 deletions commons/link/FileLinkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ public protocol FileLinkManager {

public extension FileLinkManager {

public func getDestinationPath(of: URL!, with: URL!) -> URL! {
var destinationPath: Path = ResourcePath.of(url: of);
if (QuickSymlinkDefaults(key: "relative-path-strategy", defaultValue: true).get()) {
destinationPath = destinationPath.relativize(to: ResourcePath.of(url: with?.deletingLastPathComponent()));
}

return destinationPath.toUrl();
}

public func getTargetPath(_ from: URL!, to: URL!) -> URL! {
let originSourceName = from.absoluteURL.deletingPathExtension().lastPathComponent;
let fileType = from.absoluteURL.pathExtension;
Expand Down Expand Up @@ -46,7 +55,8 @@ public class SoftLinkManager: FileLinkManager {

public func linkWith(of: URL!, with: URL!) {
do {
try FileManager.default.createSymbolicLink(at: with!, withDestinationURL: ResourcePath.of(url: of).relativize(to: ResourcePath.of(url: with?.deletingLastPathComponent())).toUrl()!);
NSLog("asdasdasd");
try FileManager.default.createSymbolicLink(at: with!, withDestinationURL: self.getDestinationPath(of: of, with: with));
} catch let error as NSError {
NSLog("FileManager.createSymbolicLink() failed to create file: %@", error.description as NSString);
}
Expand All @@ -56,7 +66,7 @@ public class SoftLinkManager: FileLinkManager {
do {
//FIXME: Add checking for existance of file & resolving this case with symply pastle link
try FileManager.default.moveItem(at: of, to: with);
try FileManager.default.createSymbolicLink(at: of, withDestinationURL: ResourcePath.of(url: with).relativize(to: ResourcePath.of(url: of.deletingLastPathComponent())).toUrl()!);
try FileManager.default.createSymbolicLink(at: of, withDestinationURL: self.getDestinationPath(of: with, with: of));
} catch let error as NSError {
NSLog("FileManager.createSymbolicLink() failed to create file: %@", error.description as NSString);
}
Expand Down
33 changes: 33 additions & 0 deletions en-GB.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Localizable.strings
quick-symlink

Created by Alexander A. Kropotin on 15/07/2021.
Copyright © 2021 Alexander A. Kropotin. All rights reserved.
*/

/* Class = "NSMenuItem"; */
"SOFT_LINK_ACTIONS_EXTENTION_NAME" = "Действия с симлинками";

/* Class = "NSMenuItem"; */
"SOFT_LINK_ACTIONS_EXTENTION_TOOL_TIP" = "Создать символьные ссылки для выбранных файлов и папок";

/* Class = "NSMenuItem"; */
"HARD_LINK_ACTIONS_EXTENTION_NAME" = "Действия с псевдонимами";

/* Class = "NSMenuItem"; */
"HARD_LINK_ACTIONS_EXTENTION_TOOL_TIP" = "Создать псевдонимы для выбранных файлов и папок";

/* Class = "NSMenuItem"; */
"COPY_PATH_ACTION_NAME" = "Скопировать путь отсюда";

/* Class = "NSMenuItem"; */
"PASTE_LINK_ACTION_NAME" = "Вставить ссылку сюда";

/* Class = "NSMenuItem"; */
"REPLACE_WITH_LINK_ACTION_NAME" = "Переместить сюда и заменить ссылкой";

/* Class = "NSMenuItem"; */
"CREATE_LINK_ACTION_NAME" = "Создать ссылку";


33 changes: 33 additions & 0 deletions en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Localizable.strings
quick-symlink

Created by Alexander A. Kropotin on 15/07/2021.
Copyright © 2021 Alexander A. Kropotin. All rights reserved.
*/

/* Class = "NSMenuItem"; */
"SOFT_LINK_ACTIONS_EXTENTION_NAME" = "Действия с симлинками";

/* Class = "NSMenuItem"; */
"SOFT_LINK_ACTIONS_EXTENTION_TOOL_TIP" = "Создать символьные ссылки для выбранных файлов и папок";

/* Class = "NSMenuItem"; */
"HARD_LINK_ACTIONS_EXTENTION_NAME" = "Действия с псевдонимами";

/* Class = "NSMenuItem"; */
"HARD_LINK_ACTIONS_EXTENTION_TOOL_TIP" = "Создать псевдонимы для выбранных файлов и папок";

/* Class = "NSMenuItem"; */
"COPY_PATH_ACTION_NAME" = "Скопировать путь отсюда";

/* Class = "NSMenuItem"; */
"PASTE_LINK_ACTION_NAME" = "Вставить ссылку сюда";

/* Class = "NSMenuItem"; */
"REPLACE_WITH_LINK_ACTION_NAME" = "Переместить сюда и заменить ссылкой";

/* Class = "NSMenuItem"; */
"CREATE_LINK_ACTION_NAME" = "Создать ссылку";


File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>quick-symlink-extension</string>
<string>hard link actions</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand Down
31 changes: 0 additions & 31 deletions quick-symlink-extension/Base.lproj/Localizable.strings

This file was deleted.

31 changes: 0 additions & 31 deletions quick-symlink-extension/en-GB.lproj/Localizable.strings

This file was deleted.

31 changes: 0 additions & 31 deletions quick-symlink-extension/en.lproj/Localizable.strings

This file was deleted.

Loading

0 comments on commit 830ddaa

Please sign in to comment.