File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -110,20 +110,24 @@ class Utils {
110
110
static func getfileSizeInBytes( forURL url: Any ) -> Double {
111
111
var fileURL : URL ?
112
112
var fileSize : Double = 0.0
113
- if ( url is URL ) || ( url is String )
114
- {
115
- if ( url is URL ) {
116
- fileURL = url as? URL
117
- }
118
- else {
119
- fileURL = URL ( fileURLWithPath: url as! String )
120
- }
121
- var fileSizeValue = 0.0
122
- try ? fileSizeValue = ( fileURL? . resourceValues ( forKeys: [ URLResourceKey . fileSizeKey] ) . allValues. first? . value as! Double ? ) !
123
- if fileSizeValue > 0.0 {
124
- fileSize = Double ( fileSizeValue)
125
- }
113
+
114
+ if ( url is URL ) {
115
+ let urlWithSlash = Utils . slashifyFilePath ( path: ( url as? URL ) ? . absoluteString)
116
+ fileURL = URL ( string: urlWithSlash!)
117
+ } else if ( url is String ) {
118
+ let urlWithSlash = Utils . slashifyFilePath ( path: url as? String )
119
+ fileURL = URL ( fileURLWithPath: urlWithSlash!)
120
+ } else {
121
+ return fileSize
122
+ }
123
+
124
+ var fileSizeValue = 0.0
125
+
126
+ try ? fileSizeValue = ( fileURL? . resourceValues ( forKeys: [ URLResourceKey . fileSizeKey] ) . allValues. first? . value as! Double ? ) !
127
+ if fileSizeValue > 0.0 {
128
+ fileSize = Double ( fileSizeValue)
126
129
}
130
+
127
131
return fileSize
128
132
}
129
133
You can’t perform that action at this time.
0 commit comments