diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..467c1a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +Pods/ +Example/Cocoapods/Podfile.lock + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..7d5c902 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +4.1 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8821505 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: objective-c +osx_image: xcode9.4 + +script: + - xcodebuild -project Francium.xcodeproj -scheme Francium -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' clean build test diff --git a/Assets/logo.png b/Assets/logo.png new file mode 100644 index 0000000..cbcc238 Binary files /dev/null and b/Assets/logo.png differ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..871805b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog Palladium + +## v1.0 (10-07-2018) +- Initial release \ No newline at end of file diff --git a/Francium.podspec b/Francium.podspec new file mode 100755 index 0000000..45d21c6 --- /dev/null +++ b/Francium.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + s.name = "Francium" + s.version = "1.0" + s.platform = :ios + s.ios.deployment_target = "10.0" + s.osx.deployment_target = "10.10" + s.summary = "A small library to use for your file system." + s.author = { "Bas van Kuijck" => "bas@e-sites.nl" } + s.license = { :type => "MIT", :file => "LICENSE" } + s.homepage = "https://github.com/e-sites/#{s.name}" + s.source = { :git => "https://github.com/e-sites/#{s.name}.git", :tag => s.version.to_s } + s.source_files = "Francium/**/*.{h,swift}" + s.requires_arc = true +end diff --git a/Francium.xcodeproj/project.pbxproj b/Francium.xcodeproj/project.pbxproj new file mode 100644 index 0000000..eb8195e --- /dev/null +++ b/Francium.xcodeproj/project.pbxproj @@ -0,0 +1,496 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + C375A4F120F8BC9300B79A89 /* Francium.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C375A4E720F8BC9300B79A89 /* Francium.framework */; }; + C375A4F620F8BC9300B79A89 /* FranciumTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C375A4F520F8BC9300B79A89 /* FranciumTests.swift */; }; + C375A4F820F8BC9300B79A89 /* Francium.h in Headers */ = {isa = PBXBuildFile; fileRef = C375A4EA20F8BC9300B79A89 /* Francium.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C375A50220F8BCAB00B79A89 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = C375A50120F8BCAB00B79A89 /* File.swift */; }; + C375A50420F8BF6A00B79A89 /* IOObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = C375A50320F8BF6A00B79A89 /* IOObject.swift */; }; + C375A50620F8BF9B00B79A89 /* Dir.swift in Sources */ = {isa = PBXBuildFile; fileRef = C375A50520F8BF9B00B79A89 /* Dir.swift */; }; + C375A50920F8C88300B79A89 /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = C375A50820F8C88300B79A89 /* Error.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + C375A4F220F8BC9300B79A89 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C375A4DE20F8BC9300B79A89 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C375A4E620F8BC9300B79A89; + remoteInfo = Francium; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + C375A4E720F8BC9300B79A89 /* Francium.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Francium.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C375A4EA20F8BC9300B79A89 /* Francium.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Francium.h; sourceTree = ""; }; + C375A4EB20F8BC9300B79A89 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C375A4F020F8BC9300B79A89 /* FranciumTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FranciumTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + C375A4F520F8BC9300B79A89 /* FranciumTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FranciumTests.swift; sourceTree = ""; }; + C375A4F720F8BC9300B79A89 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C375A50120F8BCAB00B79A89 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = ""; }; + C375A50320F8BF6A00B79A89 /* IOObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IOObject.swift; sourceTree = ""; }; + C375A50520F8BF9B00B79A89 /* Dir.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dir.swift; sourceTree = ""; }; + C375A50820F8C88300B79A89 /* Error.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C375A4E320F8BC9300B79A89 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C375A4ED20F8BC9300B79A89 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C375A4F120F8BC9300B79A89 /* Francium.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C375A4DD20F8BC9300B79A89 = { + isa = PBXGroup; + children = ( + C375A4E920F8BC9300B79A89 /* Francium */, + C375A4F420F8BC9300B79A89 /* FranciumTests */, + C375A4E820F8BC9300B79A89 /* Products */, + ); + sourceTree = ""; + }; + C375A4E820F8BC9300B79A89 /* Products */ = { + isa = PBXGroup; + children = ( + C375A4E720F8BC9300B79A89 /* Francium.framework */, + C375A4F020F8BC9300B79A89 /* FranciumTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + C375A4E920F8BC9300B79A89 /* Francium */ = { + isa = PBXGroup; + children = ( + C375A50A20F8D47600B79A89 /* IO */, + C375A50720F8C87500B79A89 /* Errors */, + C375A4EA20F8BC9300B79A89 /* Francium.h */, + C375A4EB20F8BC9300B79A89 /* Info.plist */, + ); + path = Francium; + sourceTree = ""; + }; + C375A4F420F8BC9300B79A89 /* FranciumTests */ = { + isa = PBXGroup; + children = ( + C375A4F520F8BC9300B79A89 /* FranciumTests.swift */, + C375A4F720F8BC9300B79A89 /* Info.plist */, + ); + path = FranciumTests; + sourceTree = ""; + }; + C375A50720F8C87500B79A89 /* Errors */ = { + isa = PBXGroup; + children = ( + C375A50820F8C88300B79A89 /* Error.swift */, + ); + path = Errors; + sourceTree = ""; + }; + C375A50A20F8D47600B79A89 /* IO */ = { + isa = PBXGroup; + children = ( + C375A50120F8BCAB00B79A89 /* File.swift */, + C375A50520F8BF9B00B79A89 /* Dir.swift */, + C375A50320F8BF6A00B79A89 /* IOObject.swift */, + ); + path = IO; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + C375A4E420F8BC9300B79A89 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + C375A4F820F8BC9300B79A89 /* Francium.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + C375A4E620F8BC9300B79A89 /* Francium */ = { + isa = PBXNativeTarget; + buildConfigurationList = C375A4FB20F8BC9300B79A89 /* Build configuration list for PBXNativeTarget "Francium" */; + buildPhases = ( + C375A4E220F8BC9300B79A89 /* Sources */, + C375A4E320F8BC9300B79A89 /* Frameworks */, + C375A4E420F8BC9300B79A89 /* Headers */, + C375A4E520F8BC9300B79A89 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Francium; + productName = Francium; + productReference = C375A4E720F8BC9300B79A89 /* Francium.framework */; + productType = "com.apple.product-type.framework"; + }; + C375A4EF20F8BC9300B79A89 /* FranciumTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = C375A4FE20F8BC9300B79A89 /* Build configuration list for PBXNativeTarget "FranciumTests" */; + buildPhases = ( + C375A4EC20F8BC9300B79A89 /* Sources */, + C375A4ED20F8BC9300B79A89 /* Frameworks */, + C375A4EE20F8BC9300B79A89 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C375A4F320F8BC9300B79A89 /* PBXTargetDependency */, + ); + name = FranciumTests; + productName = FranciumTests; + productReference = C375A4F020F8BC9300B79A89 /* FranciumTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C375A4DE20F8BC9300B79A89 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0940; + LastUpgradeCheck = 0940; + ORGANIZATIONNAME = "E-sites"; + TargetAttributes = { + C375A4E620F8BC9300B79A89 = { + CreatedOnToolsVersion = 9.4; + LastSwiftMigration = 0940; + }; + C375A4EF20F8BC9300B79A89 = { + CreatedOnToolsVersion = 9.4; + }; + }; + }; + buildConfigurationList = C375A4E120F8BC9300B79A89 /* Build configuration list for PBXProject "Francium" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = C375A4DD20F8BC9300B79A89; + productRefGroup = C375A4E820F8BC9300B79A89 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C375A4E620F8BC9300B79A89 /* Francium */, + C375A4EF20F8BC9300B79A89 /* FranciumTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C375A4E520F8BC9300B79A89 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C375A4EE20F8BC9300B79A89 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C375A4E220F8BC9300B79A89 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C375A50920F8C88300B79A89 /* Error.swift in Sources */, + C375A50220F8BCAB00B79A89 /* File.swift in Sources */, + C375A50420F8BF6A00B79A89 /* IOObject.swift in Sources */, + C375A50620F8BF9B00B79A89 /* Dir.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C375A4EC20F8BC9300B79A89 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C375A4F620F8BC9300B79A89 /* FranciumTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + C375A4F320F8BC9300B79A89 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C375A4E620F8BC9300B79A89 /* Francium */; + targetProxy = C375A4F220F8BC9300B79A89 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + C375A4F920F8BC9300B79A89 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + 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_DOCUMENTATION_COMMENTS = YES; + 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; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + C375A4FA20F8BC9300B79A89 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + 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_DOCUMENTATION_COMMENTS = YES; + 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; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + C375A4FC20F8BC9300B79A89 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = KH7U9B5DS2; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = Francium/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.esites.Francium; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C375A4FD20F8BC9300B79A89 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = KH7U9B5DS2; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = Francium/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.esites.Francium; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + C375A4FF20F8BC9300B79A89 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = KH7U9B5DS2; + INFOPLIST_FILE = FranciumTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.esites.FranciumTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C375A50020F8BC9300B79A89 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = KH7U9B5DS2; + INFOPLIST_FILE = FranciumTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.esites.FranciumTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C375A4E120F8BC9300B79A89 /* Build configuration list for PBXProject "Francium" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C375A4F920F8BC9300B79A89 /* Debug */, + C375A4FA20F8BC9300B79A89 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C375A4FB20F8BC9300B79A89 /* Build configuration list for PBXNativeTarget "Francium" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C375A4FC20F8BC9300B79A89 /* Debug */, + C375A4FD20F8BC9300B79A89 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C375A4FE20F8BC9300B79A89 /* Build configuration list for PBXNativeTarget "FranciumTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C375A4FF20F8BC9300B79A89 /* Debug */, + C375A50020F8BC9300B79A89 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = C375A4DE20F8BC9300B79A89 /* Project object */; +} diff --git a/Francium.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Francium.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..62eae40 --- /dev/null +++ b/Francium.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Francium.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Francium.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Francium.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Francium.xcodeproj/xcshareddata/xcschemes/Francium.xcscheme b/Francium.xcodeproj/xcshareddata/xcschemes/Francium.xcscheme new file mode 100644 index 0000000..a56e7a4 --- /dev/null +++ b/Francium.xcodeproj/xcshareddata/xcschemes/Francium.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Francium/Errors/Error.swift b/Francium/Errors/Error.swift new file mode 100644 index 0000000..09799d2 --- /dev/null +++ b/Francium/Errors/Error.swift @@ -0,0 +1,15 @@ +// +// Error.swift +// Francium +// +// Created by Bas van Kuijck on 13/07/2018. +// Copyright © 2018 E-sites. All rights reserved. +// + +import Foundation + +public enum Error: Swift.Error { + case alreadyExists + case cannotCreateFile + case directoryNotEmpty +} diff --git a/Francium/Francium.h b/Francium/Francium.h new file mode 100644 index 0000000..a763281 --- /dev/null +++ b/Francium/Francium.h @@ -0,0 +1,19 @@ +// +// Francium.h +// Francium +// +// Created by Bas van Kuijck on 13/07/2018. +// Copyright © 2018 E-sites. All rights reserved. +// + +#import + +//! Project version number for Francium. +FOUNDATION_EXPORT double FranciumVersionNumber; + +//! Project version string for Francium. +FOUNDATION_EXPORT const unsigned char FranciumVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/Francium/IO/Dir.swift b/Francium/IO/Dir.swift new file mode 100644 index 0000000..80378fc --- /dev/null +++ b/Francium/IO/Dir.swift @@ -0,0 +1,99 @@ +// +// Dir.swift +// Francium +// +// Created by Bas van Kuijck on 13/07/2018. +// Copyright © 2018 E-sites. All rights reserved. +// + +#if os(Linux) +import Glibc + +let system_glob = Glibc.glob +#else +import Darwin + +let system_glob = Darwin.glob +#endif + +import Foundation + +public class Dir: IOObject, CustomStringConvertible { + + override public var isExisting: Bool { + return isDirectory && super.isExisting + } + + public static func create(path: String, + withIntermediateDirectories: Bool = true, + permissions: Int = 0o0777) throws -> Dir { + let dir = Dir(path: path) + try dir.make(withIntermediateDirectories: withIntermediateDirectories) + dir.chmod(permissions) + return dir + } + + public func make(withIntermediateDirectories: Bool = true) throws { + if isDirectory { + throw Error.alreadyExists + } + + let attributes: [FileAttributeKey: Any] = [ + .posixPermissions: 0o777 + ] + try FileManager.default.createDirectory(atPath: absolutePath, + withIntermediateDirectories: withIntermediateDirectories, + attributes: attributes) + } + + public var description: String { + return " [ absolutePath: \(absolutePath) ]" + } + + public func glob(_ pattern: String) -> [File] { + let pattern = absolutePath + "/" + pattern + var gt = glob_t() + let cPattern = strdup(pattern) + defer { + globfree(>) + free(cPattern) + } + + let flags = GLOB_TILDE | GLOB_BRACE | GLOB_MARK + if system_glob(cPattern, flags, nil, >) == 0 { + #if os(Linux) + let matchc = gt.gl_pathc + #else + let matchc = gt.gl_matchc + #endif + + return (0.. File { + let file = File(path: path) + try file.create() + file.chmod(permissions) + return file + } + + public func create() throws { + if isExisting { + throw Error.alreadyExists + } + + let attributes: [FileAttributeKey: Any] = [ + .posixPermissions: 0o777 + ] + + if !FileManager.default.createFile(atPath: absolutePath, contents: nil, attributes: attributes) { + throw Error.cannotCreateFile + } + } + + public var description: String { + return " [ absolutePath: \(absolutePath) ]" + } +} + +extension File { + public func write(data: Data) throws { + try data.write(to: url) + } + + public func write(string: String) throws { + let data = string.data(using: .utf8) ?? Data() + try write(data: data) + } + + public func append(string: String) throws { + let data = string.data(using: .utf8) ?? Data() + try append(data: data) + } + + public func append(data: Data) throws { + if !isExisting { + try write(data: data) + return + } + + guard let fileHandle = FileHandle(forUpdatingAtPath: path) else { + try write(data: data) + return + } + + defer { + fileHandle.closeFile() + } + fileHandle.seekToEndOfFile() + fileHandle.write(data) + } + + public func read() throws -> Data { + return try Data(contentsOf: url) + } + + public var contents: String? { + do { + let data = try read() + return String(data: data, encoding: .utf8) + } catch { + return nil + } + } +} diff --git a/Francium/IO/IOObject.swift b/Francium/IO/IOObject.swift new file mode 100644 index 0000000..e23f60a --- /dev/null +++ b/Francium/IO/IOObject.swift @@ -0,0 +1,120 @@ +// +// Pointer.swift +// Francium +// +// Created by Bas van Kuijck on 13/07/2018. +// Copyright © 2018 E-sites. All rights reserved. +// + +import Foundation + +public class IOObject { + + public let path: String + let url: URL + + public init(path: String) { + self.path = path + self.url = URL(fileURLWithPath: path) + } + + public var absolutePath: String { + return url.path + } + + public var isExisting: Bool { + return FileManager.default.fileExists(atPath: absolutePath) + } + + public var basename: String { + return url.lastPathComponent + } + + public var name: String { + var expl = url.lastPathComponent.components(separatedBy: ".") + expl.removeLast() + return expl.joined(separator: ".") + } + + public var isDirectory: Bool { + var isDir: ObjCBool = false + if FileManager.default.fileExists(atPath: path, isDirectory: &isDir) { + return isDir.boolValue + } else { + return false + } + } + + public var dirName: String { + var components = url.pathComponents + if !isDirectory { + components.removeLast() + } + + if components.last == "" { + components.removeLast() + } + return components.joined(separator: "/") + } + + + public var modificationDate: Date? { + return _attribute(type: Date.self, for: .modificationDate) + } + + public var creationDate: Date? { + return _attribute(type: Date.self, for: .creationDate) + } +} + +extension IOObject { + public func delete() throws { + try FileManager.default.removeItem(atPath: absolutePath) + } +} + +extension IOObject { + public func rename(to newName: String) throws { + try move(to: Dir(path: dirName), newName: newName) + } + + public func move(to dir: Dir, newName: String? = nil) throws { + try FileManager.default.moveItem(atPath: absolutePath, toPath: dir.dirName + "/" + (newName ?? basename)) + } + + public func copy(to dir: Dir, newName: String? = nil) throws { + try FileManager.default.copyItem(atPath: absolutePath, toPath: dir.dirName + "/" + (newName ?? basename)) + } +} + +extension IOObject { + public func chmod(_ value: Int) { + _setAttribute(value: value, for: .posixPermissions) + } + + public var permissions: Int? { + return _attribute(type: Int.self, for: .posixPermissions) + } +} + +extension IOObject { + fileprivate func _attribute(type: T.Type, `for` key: FileAttributeKey) -> T? { + do { + let attributes = try FileManager.default.attributesOfItem(atPath: absolutePath) + return attributes[key] as? T + + } catch { + return nil + } + } + + fileprivate func _setAttribute(value: Any, for key: FileAttributeKey) { + do { + var attributes = try FileManager.default.attributesOfItem(atPath: absolutePath) + attributes[key] = value + try FileManager.default.setAttributes(attributes, ofItemAtPath: absolutePath) + } catch { + } + } +} + diff --git a/Francium/Info.plist b/Francium/Info.plist new file mode 100644 index 0000000..1007fd9 --- /dev/null +++ b/Francium/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/FranciumTests/FranciumTests.swift b/FranciumTests/FranciumTests.swift new file mode 100644 index 0000000..563d0b8 --- /dev/null +++ b/FranciumTests/FranciumTests.swift @@ -0,0 +1,93 @@ +// +// FranciumTests.swift +// FranciumTests +// +// Created by Bas van Kuijck on 13/07/2018. +// Copyright © 2018 E-sites. All rights reserved. +// + +import XCTest +@testable import Francium + +class FranciumTests: XCTestCase { + + override func setUp() { + super.setUp() + } + + private func _createTestDirectory() { + + } + + func testFile() { + let file = File(path: "somenewfile.txt") + XCTAssertEqual(file.isExisting, false) + XCTAssertEqual(file.basename, "somenewfile.txt") + XCTAssertEqual(file.name, "somenewfile") + XCTAssertEqual(file.extensionName, "txt") + XCTAssertNil(file.creationDate) + XCTAssertNil(file.modificationDate) + } + + func testDir() { + let dir = Dir(path: "./") + XCTAssertEqual(dir.isExisting, true) + XCTAssertEqual(dir.isDirectory, true) + XCTAssertNotNil(dir.creationDate) + XCTAssertNotNil(dir.modificationDate) + } + + func testCreation() { + do { + let dir = try Dir.create(path: "./SomeNewDirectory") + XCTAssertNotNil(dir.creationDate) + XCTAssertEqual(dir.permissions, 0o0777) + XCTAssertEqual(dir.basename, "SomeNewDirectory") + + let file = try File.create(path: "./SomeNewDirectory/somenewfile.txt") + XCTAssertEqual(file.permissions, 0o0777) + XCTAssertNotNil(file.creationDate) + XCTAssertEqual(file.basename, "somenewfile.txt") + try file.write(string: "Some information") + XCTAssertEqual(file.contents, "Some information") + + XCTAssertEqual(dir.glob("*").count, 1) + XCTAssertEqual(dir.glob("some*").count, 1) + XCTAssertEqual(dir.glob("*.txt").count, 1) + XCTAssertEqual(dir.glob("*.md").count, 0) + try file.delete() + try dir.delete() + } catch let error { + XCTAssert(false, "\(error)") + } + } + + func testEmpty() { + do { + let dir = try Dir.create(path: "./SomeNewDirectory") + let file = try File.create(path: "./SomeNewDirectory/somenewfile.txt") + try dir.empty() + XCTAssertEqual(dir.glob("*").count, 0) + XCTAssertEqual(file.isExisting, false) + try dir.delete() + + } catch let error { + XCTAssert(false, "\(error)") + } + } + + func testAppend() { + do { + let file = try File.create(path: "./somenewfile.txt") + try file.write(string: "Some information") + XCTAssertEqual(file.contents, "Some information") + try file.append(string: ">>>") + XCTAssertEqual(file.contents, "Some information>>>") + + try file.delete() + + } catch let error { + XCTAssert(false, "\(error)") + } + } +} diff --git a/FranciumTests/Info.plist b/FranciumTests/Info.plist new file mode 100644 index 0000000..6c40a6c --- /dev/null +++ b/FranciumTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fa46df0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 E-sites + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.