nvzqz / filekit Goto Github PK
View Code? Open in Web Editor NEWSimple and expressive file management in Swift
Home Page: https://nvzqz.github.io/FileKit/docs/
License: MIT License
Simple and expressive file management in Swift
Home Page: https://nvzqz.github.io/FileKit/docs/
License: MIT License
Hi,
When I build your component with carthage I have these warnings:
../Sources/Carthage/Checkouts/FileKit/Sources/Path.swift:1066:17: warning: 'ExpressibleByStringInterpolation' is deprecated: it will be replaced or redesigned in Swift 4.0. Instead of conforming to 'ExpressibleByStringInterpolation', consider adding an 'init(_:String)'
../Sources/Carthage/Checkouts/FileKit/Sources/TextFile.swift:231:21: warning: conditional downcast from 'NSString?' to 'String' is a bridging conversion; did you mean to use 'as'?
I've used FileKit for a while now, but a problem has plagued me often.
I'm never able to po anything FileKit related.
Any ideas why this is the case?
for example :
(lldb) po name
expression produced error: error: /var/folders/cs/51wtzgp51v157z25_b0fjqn80000gn/T/expr10-5d206b..swift:1:85: error: 'Path' is not a member type of 'FileKit'
Swift._DebuggerSupport.stringForPrintObject(Swift.UnsafePointer<Swift.Array<FileKit.Path>>(bitPattern: 0x1037ff9e0)!.pointee)
~~~~~~~ ^
I don't want to store json in plain text which user can change. Is there any way to encrypt or decrypt or even hide that file.
I got an error when try to move it using function moveTo()
on Path
.
Hi,
how can I obtain the children of a Path
sorted by descendant modified date, for example?
I noticed that FileKit is based on NSFileHandle. NSFileHandle has an API that is based on (Objective-C) exceptions. The FileKit codebase currently does not catch those. IMO, this is required to make it possible to safely use FileKit (without arbitrary application terminations).
In Image+FileKit.swift on line 66 I get the following error:
'pngData()' has been renamed to 'UIImagePNGRepresentation(_:)'
Changing self.pngData()
to UIImagePNGRepresentation(self)
solves the issue. Please, kindly update.
Can you allow Path.UsersDocuments for iOS in addition to OSX?
And can you make Path.pathInUserDomain, Path.pathsInDomains public? This way I can extend Path with more iOS paths such as UsersDocuments
PR #44 fixes the build error, but these changes have not been released yet. When will you release these as a minor version update?
Setting .pathExtension
replaces any possible path extension on the Path, even if it doesn't actually have one (e.g. a file named "Image 2019-09-18 19.43.38.067"). Path needs append(extension: String)
or some such.
Code Example
print(Path.userDesktop.children().count) // 0
print(Path("my path with children").children().count) // 0
Now, both of the paths that I tested with do have children but the .children()
method seems to always return 0.
I was using version 5.0.0
with Swift 4 on a Mac OS app.
Why is it that there are no file read and write routines to read individual lines from a file, or write individual lines to a file, without having to open and close the file around each line (such as your |>> operator)?
I really love the Swift language, except that I can't read or write a text file in a normal manner. Reading the whole file at once is great... unless your file is several Megabytes, or several Terabytes long. I really just want to read a file, line by line, in a way that won't eat up all of memory.
I'm just frustrated, saw your library, and thought that it might be the solution I was looking for. O.o
A shell task (/usr/bin/xcrun xcodebuild -project /Users/NEO/Workspace/Swift3/hsound/HSound/Carthage/Checkouts/FileKit/FileKit.xcodeproj -scheme FileKit-iOS -configuration Release -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
** BUILD FAILED **
The following build commands failed:
CompileSwift normal arm64
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
I read the release notes for v3.0.0, and "File system watching" caught my eye. I need to do file system watching in my application so that I can update a CollectionView as the contents of a directory change.
I don't see where usage of this feature is documented. Can you point me to where it is, or if there isn't any documentation, can you please provide some? I would love to take advantage of this feature.
Thanks!
Swiftlint display some errors of type Shorthand Operator Violation: Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning. (shorthand_operator)
( maybe false positive realm/SwiftLint#1157 )
Xcode9
after pod install
Swift Compiler Error Group:
/Users/matthewxu/project/LiLiTools/Pods/FileKit/Sources/FileProtection.swift:126:82: Cannot convert value of type '[FileAttributeKey : Any]' to expected argument type '[String : Any]?'
on manager.createFile(atPath: _safeRawValue, contents: nil, attributes: attributes) {
in the following codes
public func createFile(_ fileProtection: FileProtection) throws {
let manager = FileManager()
let attributes: [FileAttributeKey : Any] = [.protectionKey: fileProtection] // todo test
if !manager.createFile(atPath: _safeRawValue, contents: nil, attributes: attributes) {
throw FileKitError.createFileFail(path: self)
}
}
Any one meet this issue and how to solve it
I would like a release tag including @Dschee 's contributions #18 .
FileKit/Sources/TextFile.swift
Line 299 in 38fb743
The method may crash an app.
Can you replace with a safe method?
When adding a String
to a Path
, if the Path
ends with /
and the String
starts with /
then the results include AnySequence
garbage.
import FileKit
print(Path("/Foo/bar/") + "/wat")
// prints:
// /Foo/bar/AnySequence<Path>(_box: Swift._SequenceBox<Swift._DropFirstSequence<FileKit.DirectoryEnumerator>>)
Tested with the latest develop
(7521741) on Swift 4.1.2.
It would be great to have a way to add/remove extended file attributes. For example, If I wanted to associate different display name for file rather than original name of file. In such case, extended file attributes can come in handy.
I am getting a file base64 string from alamofire . how to save as a file
Although FileKit is a really great library, I have a small problem with it.
Situation: I want to copy a file from one location to another location with a different name. With the copyToPath
method I get the file with the original name from path1 to path2. But: How do I rename the file there? Changing the name does not succeed, as name is read-only. So, I'm stuck a bit...
Perhaps you might give me hint for that - thanks a lot in advance!
I was just wondering what the release notes for v4.0.0 are. On your releases page there are no release notes. I'd like to know what the changes are so I can upgrade accordingly.
Thanks!
When I try the below
Path.UserDocuments
Path has no members UserDocuments
it has only 3 UserCache, UserHome, UserTemporary
I am getting a single error on the latest release of FileKit (5.2.0), the error is:
Value of type 'UIImage' has no member 'pngData'
Examples in README.md
use the old API style.
I tried FileKit.Path
with no gain.
Future API should be written to be compatible with Swift 3.
Because Swift 2 support is being dropped, this is a breaking change that will result in a major version change for FileKit to 4.0.0.
Also, a lot of documentation is also either ambiguous or just weirdly worded.
Cleaning up the API entails following the Swift API Style Guidelines.
Note: Adding Swift 3 support consists of keeping this up to date with Swift 3 until a final release is made. Then there'll be no breaking changes, allowing for version 4.
If yes then what the path that should be used and what changes are required for xcode project to support icloud on macOS
I was able to find this issue #73 but I do not understand why it was closed without any resolution. Does no-one maintaining this project have access to update the Podspec in the public CocoaPods repo? I am happy to help in anyway I can to make this happen. Thanks!
Hi, will FileKit support Linux as well? Currently I'm not able to build 3.0.0 tag due issue with Image+File.swift where is WatchKit imported, which is something that doesn't exist on Linux version of Swift.
Thanks.
When testing FileKit, testWatch() will sometimes fail on the first attempt. I'm not familiar with GCD, so I don't necessarily know why this occurs.
Hi,
I'm getting a compiler error when building my macOS app using FileKit integrated with Cocoapods.
The app is for macOS 10.13. I'm using Xcode 9.0.1, Cocoapods and FileKit 4.0.1 (5.0.0 was not available over Cocoapods)
If I want to compile the I getting this error:
Static let 'NowEventId' is internal and cannot be referenced from a default argument value
public init(paths: [Path],
sinceWhen: FSEventStreamEventId = FileSystemEvent.NowEventId,
flags: FileSystemEventStreamCreateFlags = [.UseCFTypes, .FileEvents],
latency: CFTimeInterval = 0,
queue: DispatchQueue? = nil,
callback: @escaping (FileSystemEvent) -> Void
) {
self.lastEventId = sinceWhen
self.paths = paths
self.flags = flags
self.latency = latency
self.queue = queue
self._callback = callback
}
I'm not sure if this is an oversight, but there's no default conformance for Codable
to ReadableWriteable
.
This conformance would allow for File<DataType: ReadableWritable>
to work with any Codable
and appears to be the intent as listed in the readme.
When do you plan to add support for Swift 4
Your podspec/releases show 5.1.0
, but cocoapods only has up to 5.0.0
. Please run pod trunk push
to update cocoapods with your latest podspec. Thanks!
I just tried building this on an linux machine running Ubuntu 16.04 with swift 3.0.1 and there were several build errors.
I will attempt running this on my macOS laptop to see if I get the same failures
It's have a easy method to get relative path?
In the past, I try to make some utility functions to work with NSCoding (branch feature-nscoding), write and read JSON
In swift 4 Decodable/Encodable (and Codable) allow to have a better interface to serialize objects
We can
Encodable
objectEncodable
objectsDecodable
objectDecodable
objectsThat could be done only after merging #49
Hi, I just ran into a case where I had to user a hard link instead of a symlink and had to fall back to NSFileManager to accomplish it. The API is almost identical to the symlink function:
createSymbolicLinkAtURL(_:withDestinationURL:)
createSymbolicLinkAtPath(_:withDestinationPath:)
linkItemAtURL(_:toURL:)
linkItemAtPath(_:toPath:)
Thanks! If I have some time I'll add this and submit a PR, but I wanted to at least raise the flag so the issue is logged.
Is there no way to get file base name (filename without extension)?
+>! Operator
Forcibly copies the file at the left path to the right path by deleting anything at the left path before copying the file.
Should that be "Forcibly copies the file at the left path to the right path by deleting anything at the RIGHT path before copying the file." ? If not, wouldn't it be a move instead of a copy?
del, sorry, found everything
pod latest version is v5.2.0, I have already update pod repo... Thanks...
Hi,
I'm getting a compiler error when building my macOS app using FileKit integrated with Cocoapods.
The app is for macOS 10.13. I'm using Xcode 9.0.1, Cocoapods and FileKit 4.0.1 (5.0.0 was not available over Cocoapods)
If I want to compile the I getting this error:
Cannot call value of non-function type 'FileType?'
in
extension File: CustomStringConvertible {
// MARK: - CustomStringConvertible
/// A textual representation of `self`.
public var description: String {
return String(describing: type(of: self)) + "('" + path.description + "')"
}
}
let shared = Path.userDocuments
let x = shared + "h/ai"
try? x.createDirectory(withIntermediateDirectories: true)
let sample = TextFile(path: shared/"filekit_sample.txt")
try? sample.write("Hello there!")
try? sample.read()
This code always create two directory h and sub directory ai.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.