Skip to content

Commit

Permalink
Merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
Nixon Shih committed Dec 11, 2018
2 parents b799c3d + 34c8c0c commit c9ab4f4
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 80 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

#### Releases
- `1.x` Releases - [1.5.0](#150-2018-12-11) | [1.4.0](#140-2017-10-06) | [1.3.0](#130-2016-11-10) | [1.2.0](#120-2016-10-20) | [1.1.0](#110-2016-10-14)

## [Unreleased]
### Added
- Localization

## [1.5.0] - 2018-12-11
### Updated
- Support Swift 4.2

## [1.4.0] - 2017-10-06
### Updated
- Support Swift 4.0

## [1.3.0] - 2016-11-10
### Updated
- Support Swift 3.0

## [1.2.0] - 2016-10-20
### Added
- Feature of user preference.

## [1.1.0] - 2016-10-14
### Added
- Feature of exclude folder from search
20 changes: 16 additions & 4 deletions CheckDuplicateFileName.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
25243B121DA785D400DE4029 /* SearchResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25243B0B1DA785D400DE4029 /* SearchResult.swift */; };
25243B131DA785D400DE4029 /* SelectDirectoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25243B0C1DA785D400DE4029 /* SelectDirectoryViewController.swift */; };
25243B161DA785DD00DE4029 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 25243B141DA785DD00DE4029 /* Main.storyboard */; };
25E3BF3121BEC2100046EB60 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 25E3BF3021BEC2100046EB60 /* README.md */; };
EDB0683521BF678000BEAC54 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = EDB0683421BF678000BEAC54 /* CHANGELOG.md */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -30,6 +32,8 @@
25243B0C1DA785D400DE4029 /* SelectDirectoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SelectDirectoryViewController.swift; path = CheckDuplicateFileName/SelectDirectoryViewController.swift; sourceTree = SOURCE_ROOT; };
25243B151DA785DD00DE4029 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = CheckDuplicateFileName/Base.lproj/Main.storyboard; sourceTree = SOURCE_ROOT; };
25BF97111DA4944700EABEB6 /* CheckDuplicateFileName.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CheckDuplicateFileName.app; sourceTree = BUILT_PRODUCTS_DIR; };
25E3BF3021BEC2100046EB60 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
EDB0683421BF678000BEAC54 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -48,6 +52,8 @@
children = (
25BF97131DA4944700EABEB6 /* CheckSameFileName */,
25BF97121DA4944700EABEB6 /* Products */,
25E3BF3021BEC2100046EB60 /* README.md */,
EDB0683421BF678000BEAC54 /* CHANGELOG.md */,
);
sourceTree = "<group>";
};
Expand All @@ -73,7 +79,7 @@
25243B081DA785D400DE4029 /* Info.plist */,
25243B141DA785DD00DE4029 /* Main.storyboard */,
);
path = CheckSameFileName;
name = CheckSameFileName;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -103,7 +109,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = Nixon;
TargetAttributes = {
25BF97101DA4944700EABEB6 = {
Expand Down Expand Up @@ -135,8 +141,10 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
25E3BF3121BEC2100046EB60 /* README.md in Resources */,
25243B161DA785DD00DE4029 /* Main.storyboard in Resources */,
25243B0E1DA785D400DE4029 /* Assets.xcassets in Resources */,
EDB0683521BF678000BEAC54 /* CHANGELOG.md in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -184,12 +192,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -238,12 +248,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -285,7 +297,7 @@
PRODUCT_NAME = CheckDuplicateFileName;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -301,7 +313,7 @@
PRODUCT_BUNDLE_IDENTIFIER = net.NixonDesign.CheckDuplicateFileName;
PRODUCT_NAME = CheckDuplicateFileName;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion CheckDuplicateFileName/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by NixonShih on 2016/10/5.
// Copyright © 2016 Nixon. All rights reserved.
// Copyright © 2019 Nixon. All rights reserved.
//

import Cocoa
Expand Down
6 changes: 3 additions & 3 deletions CheckDuplicateFileName/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.0</string>
<string>1.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.4.0</string>
<string>1.5.0.0</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.business</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Nixon. All rights reserved.</string>
<string>Copyright © 2019 Nixon. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
Expand Down
4 changes: 2 additions & 2 deletions CheckDuplicateFileName/LogoInfoViewController.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by NixonShih on 2016/10/20.
// Copyright © 2016 Nixon. All rights reserved.
// Copyright © 2019 Nixon. All rights reserved.
//

import Cocoa
Expand Down Expand Up @@ -32,7 +32,7 @@ class LogoInfoViewController: NSViewController {
case 1:
SearchPreferences.shared.isStorageEnable = true
default:
break
fatalError("Unknown selection.")
}
}

Expand Down
59 changes: 28 additions & 31 deletions CheckDuplicateFileName/SearchFileBrain.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by NixonShih on 2016/10/6.
// Copyright © 2016 Nixon. All rights reserved.
// Copyright © 2019 Nixon. All rights reserved.
//

import Foundation
Expand Down Expand Up @@ -47,7 +47,7 @@ protocol SearchFileBrainDelegate {
*/
class SearchFileBrain {

/** 想要搜尋的路徑 */
/// a path that you want to search
let directoryPath: String
/** 只要存放在這個陣列的路徑,搜尋的時候都會排除。 */
var excludeFolders: [String]?
Expand All @@ -60,11 +60,11 @@ class SearchFileBrain {
private var cancelSearchFlag = false

/**
負責初始化 SearchFileBrain 這個 Class
Initializer
- parameter directoryPath: 想要搜尋的路徑
- parameter excludeFolders: 想要排除在搜尋之外的資料夾
- parameter excludeFileNames: 想要排除在搜尋之外的檔案名稱
- parameter directoryPath: a path that you want to search
- parameter excludeFolders: folder names that you want to exclude
- parameter excludeFileNames: file names that you want to exclude
- returns: SearchFileBrain's Instance
*/
init(directoryPath: String, excludeFolders: [String]?, excludeFileNames: [String]?) {
Expand All @@ -91,6 +91,7 @@ class SearchFileBrain {

/** 開始對資料夾進行檢索比對 */
private func enumeratorDirectory() {

let fileManager = FileManager.default
let keys = [URLResourceKey.isDirectoryKey]

Expand All @@ -103,31 +104,27 @@ class SearchFileBrain {
if cancelSearchFlag { return }

var isDir : ObjCBool = false
if fileManager.fileExists(atPath: (fileURL as AnyObject).path!, isDirectory: &isDir) {
if !isDir.boolValue {
let aFileURL = fileURL as! URL

if checkNeedExcludeOf(FolderPath: aFileURL.absoluteString) { continue }
if checkNeedExcludeOf(FileName: aFileURL.lastPathComponent) { continue }

let theSearchResult = SearchResult(fileURL: aFileURL)

if theSearchResult.fileName == ".DS_Store" {
continue
}

var duplicateFiles = duplicateFilesInStorage(aFileURL)

if duplicateFiles.count == 0 {
searchResultStorage.append(theSearchResult)
}else{
duplicateFiles.append(theSearchResult)

DispatchQueue.main.async(execute: {
self.delegate?.foundDuplicateFile(self,duplicateFiles: duplicateFiles)
})
}
}
guard
fileManager.fileExists(atPath: (fileURL as AnyObject).path!, isDirectory: &isDir),
!isDir.boolValue,
let aFileURL = fileURL as? URL,
checkNeedExcludeOf(FolderPath: aFileURL.absoluteString),
checkNeedExcludeOf(FileName: aFileURL.lastPathComponent)
else { continue }

let theSearchResult = SearchResult(fileURL: aFileURL)
if theSearchResult.fileName == ".DS_Store" { continue }

var duplicateFiles = duplicateFilesInStorage(aFileURL)

if duplicateFiles.count == 0 {
searchResultStorage.append(theSearchResult)
}else{
duplicateFiles.append(theSearchResult)

DispatchQueue.main.async(execute: {
self.delegate?.foundDuplicateFile(self,duplicateFiles: duplicateFiles)
})
}
}

Expand Down
16 changes: 8 additions & 8 deletions CheckDuplicateFileName/SearchFileNameResultViewController.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by NixonShih on 2016/10/6.
// Copyright © 2016 Nixon. All rights reserved.
// Copyright © 2019 Nixon. All rights reserved.
//

import Cocoa
Expand All @@ -14,17 +14,17 @@ class SearchFileNameResultViewController: NSViewController {
/** 想要排除在搜尋之外的檔案名稱 */
var excludeFileNames: [String]?

@IBOutlet fileprivate weak var searchStatusLabel: NSTextField!
@IBOutlet fileprivate weak var searchStatusIndicator: NSProgressIndicator!
@IBOutlet private weak var searchStatusLabel: NSTextField!
@IBOutlet private weak var searchStatusIndicator: NSProgressIndicator!
@IBOutlet private weak var searchResultTableView: NSTableView!

/** 存放已經排序的結果 */
fileprivate var searchResultDataSource = [SearchResult]()
private var searchResultDataSource = [SearchResult]()
/** 存放尚未排序的結果 */
fileprivate var tempSearchResult = [SearchResult]()
private var tempSearchResult = [SearchResult]()
private var searchFileBrain: SearchFileBrain?
/** 負責更新畫面的 Timer */
fileprivate var reloadTimer: Timer?
private var reloadTimer: Timer?

// MARK: - ViewController Life Cycle

Expand Down Expand Up @@ -95,14 +95,14 @@ class SearchFileNameResultViewController: NSViewController {
}
}

@objc fileprivate func sortAndReload() {
@objc private func sortAndReload() {
searchResultDataSource = tempSearchResult.sorted { $0.fileName < $1.fileName }
searchResultTableView.reloadData()
}

// MARK: - Data

fileprivate func checkURLExist(_ searchResult: SearchResult) -> Bool {
private func checkURLExist(_ searchResult: SearchResult) -> Bool {
let filter = tempSearchResult.filter{
$0.fileURL.absoluteString == searchResult.fileURL.absoluteString
}
Expand Down
2 changes: 1 addition & 1 deletion CheckDuplicateFileName/SearchPreferences.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by NixonShih on 2016/10/20.
// Copyright © 2016 Nixon. All rights reserved.
// Copyright © 2019 Nixon. All rights reserved.
//

import Foundation
Expand Down
11 changes: 4 additions & 7 deletions CheckDuplicateFileName/SearchResult.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
//
// Created by NixonShih on 2016/10/6.
// Copyright © 2016 Nixon. All rights reserved.
// Copyright © 2019 Nixon. All rights reserved.
//

import Foundation

/**
**SearchResult**
這個 Struct 是存放搜尋資料的Model
*/
/// SearchResult
///
/// Include a result of file search
struct SearchResult {

let fileURL: URL
Expand Down
Loading

0 comments on commit c9ab4f4

Please sign in to comment.