浏览代码

Add Tags for directory

Marino Faggiana 6 年之前
父节点
当前提交
8bb81b9f2a
共有 2 个文件被更改,包括 7 次插入10 次删除
  1. 5 3
      PickerFileProvider/FileProviderData.swift
  2. 2 7
      PickerFileProvider/FileProviderEnumerator.swift

+ 5 - 3
PickerFileProvider/FileProviderData.swift

@@ -85,9 +85,11 @@ class FileProviderData: NSObject {
             try FileManager.default.createDirectory(atPath: identifierPath, withIntermediateDirectories: true, attributes: nil)
             try FileManager.default.createDirectory(atPath: identifierPath, withIntermediateDirectories: true, attributes: nil)
         } catch { }
         } catch { }
         
         
-        // If do not exists create file with size = 0
-        if FileManager.default.fileExists(atPath: fileIdentifier) == false {
-            FileManager.default.createFile(atPath: fileIdentifier, contents: nil, attributes: nil)
+        if metadata.directory == false {
+            // If do not exists create file with size = 0
+            if FileManager.default.fileExists(atPath: fileIdentifier) == false {
+                FileManager.default.createFile(atPath: fileIdentifier, contents: nil, attributes: nil)
+            }
         }
         }
     }
     }
     
     

+ 2 - 7
PickerFileProvider/FileProviderEnumerator.swift

@@ -81,10 +81,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
                     continue
                     continue
                 }
                 }
                 
                 
-                // create file on File System
-                if metadata.directory == false {
-                    providerData.createFileIdentifierOnFileSystem(metadata: metadata)
-                }
+                providerData.createFileIdentifierOnFileSystem(metadata: metadata)
                     
                     
                 itemIdentifierMetadata[providerData.getItemIdentifier(metadata: metadata)] = metadata
                 itemIdentifierMetadata[providerData.getItemIdentifier(metadata: metadata)] = metadata
             }
             }
@@ -229,9 +226,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
             counter += 1
             counter += 1
             if (counter >= start && counter <= stop) {
             if (counter >= start && counter <= stop) {
                 
                 
-                if metadata.directory == false {
-                    providerData.createFileIdentifierOnFileSystem(metadata: metadata)
-                }
+                providerData.createFileIdentifierOnFileSystem(metadata: metadata)
 
 
                 let parentItemIdentifier = providerData.getParentItemIdentifier(metadata: metadata)
                 let parentItemIdentifier = providerData.getParentItemIdentifier(metadata: metadata)
                 if parentItemIdentifier != nil {
                 if parentItemIdentifier != nil {