|
7 | 7 | //
|
8 | 8 | #if !os(Windows)
|
9 | 9 |
|
| 10 | +#if canImport(Android) |
| 11 | +import Android |
| 12 | +#endif |
| 13 | + |
10 | 14 | #if os(Android) && (arch(i386) || arch(arm)) // struct stat.st_mode is UInt32
|
11 | 15 | internal func &(left: UInt32, right: mode_t) -> mode_t {
|
12 | 16 | return mode_t(left) & right
|
@@ -345,7 +349,14 @@ extension FileManager {
|
345 | 349 | defer { ps.deallocate() }
|
346 | 350 | ps.initialize(to: UnsafeMutablePointer(mutating: fsRep))
|
347 | 351 | ps.advanced(by: 1).initialize(to: nil)
|
348 |
| - return fts_open(ps, FTS_PHYSICAL | FTS_XDEV | FTS_NOCHDIR | FTS_NOSTAT, nil) |
| 352 | + return ps.withMemoryRebound(to: UnsafeMutablePointer<CChar>.self, capacity: 2) { rebound_ps in |
| 353 | +#if canImport(Android) |
| 354 | + let arg = rebound_ps |
| 355 | +#else |
| 356 | + let arg = ps |
| 357 | +#endif |
| 358 | + return fts_open(arg, FTS_PHYSICAL | FTS_XDEV | FTS_NOCHDIR | FTS_NOSTAT, nil) |
| 359 | + } |
349 | 360 | }
|
350 | 361 | if _stream == nil {
|
351 | 362 | throw _NSErrorWithErrno(errno, reading: true, url: url)
|
@@ -392,13 +403,13 @@ extension FileManager {
|
392 | 403 |
|
393 | 404 | _current = fts_read(stream)
|
394 | 405 | while let current = _current {
|
395 |
| - let filename = FileManager.default.string(withFileSystemRepresentation: current.pointee.fts_path, length: Int(current.pointee.fts_pathlen)) |
| 406 | + let filename = FileManager.default.string(withFileSystemRepresentation: current.pointee.fts_path!, length: Int(current.pointee.fts_pathlen)) |
396 | 407 |
|
397 | 408 | switch Int32(current.pointee.fts_info) {
|
398 | 409 | case FTS_D:
|
399 | 410 | let (showFile, skipDescendants) = match(filename: filename, to: _options, isDir: true)
|
400 | 411 | if skipDescendants {
|
401 |
| - fts_set(_stream, _current, FTS_SKIP) |
| 412 | + fts_set(stream, _current!, FTS_SKIP) |
402 | 413 | }
|
403 | 414 | if showFile {
|
404 | 415 | return URL(fileURLWithPath: filename, isDirectory: true)
|
@@ -572,7 +583,7 @@ extension FileManager {
|
572 | 583 | let finalErrno = originalItemURL.withUnsafeFileSystemRepresentation { (originalFS) -> Int32? in
|
573 | 584 | return newItemURL.withUnsafeFileSystemRepresentation { (newItemFS) -> Int32? in
|
574 | 585 | // This is an atomic operation in many OSes, but is not guaranteed to be atomic by the standard.
|
575 |
| - if rename(newItemFS, originalFS) == 0 { |
| 586 | + if rename(newItemFS!, originalFS!) == 0 { |
576 | 587 | return nil
|
577 | 588 | } else {
|
578 | 589 | return errno
|
|
0 commit comments