checkVFSFolder : Checks whether the Folder exists in provided virtual filesystem, if not, the Folder is created
(path string, vfs avfs.VFS)
| 51 | |
| 52 | // checkVFSFolder : Checks whether the Folder exists in provided virtual filesystem, if not, the Folder is created |
| 53 | func checkVFSFolder(path string, vfs avfs.VFS) (err error) { |
| 54 | |
| 55 | var debug string |
| 56 | _, err = vfs.Stat(filepath.Dir(path)) |
| 57 | |
| 58 | if fsIsNotExistErr(err) { |
| 59 | // Folder does not exist, will now be created |
| 60 | |
| 61 | // If we are on Windows and the cache location path is NOT on C:\ we need to create the volume it is located on |
| 62 | // Failure to do so here will result in a panic error and the stream not playing |
| 63 | vm := vfs.(avfs.VolumeManager) |
| 64 | if vfs.OSType() == avfs.OsWindows && avfs.VolumeName(vfs, path) != "C:" { |
| 65 | vm.VolumeAdd(path) |
| 66 | } |
| 67 | |
| 68 | err = vfs.MkdirAll(getPlatformPath(path), 0755) |
| 69 | if err == nil { |
| 70 | |
| 71 | debug = fmt.Sprintf("Create virtual filesystem Folder:%s", path) |
| 72 | showDebug(debug, 1) |
| 73 | |
| 74 | } else { |
| 75 | return err |
| 76 | } |
| 77 | |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | // fsIsNotExistErr : Returns true whether the <err> is known to report that a file or directory does not exist, |
| 85 | // including virtual file system errors |
no test coverage detected