diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 90eec57..eb17a9f 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -24,10 +24,10 @@ import std.algorithm : countUntil, filter, map, sort, canFind, remove; import std.array; import std.conv; +import std.datetime.systime; import std.digest.sha; import std.encoding : sanitize; import std.exception; -import std.file; import std.range; import std.string; import std.zip; @@ -810,7 +810,7 @@ assert(!name.sub.length, "Cannot store a subpackage, use main package instead"); NativePath dstpath = this.getPackagePath(dest, name, vers.toString()); - ensureDirectory(dstpath.parentPath()); + this.ensureDirectory(dstpath.parentPath()); const lockPath = dstpath.parentPath() ~ ".lock"; // possibly wait for other dub instance @@ -861,18 +861,18 @@ else return NativePath(path.bySegment.array[zip_prefix.length .. $]); } - static void setAttributes(string path, ArchiveMember am) + void setAttributes(NativePath path, ArchiveMember am) { import std.datetime : DosFileTimeToSysTime; auto mtime = DosFileTimeToSysTime(am.time); - setTimes(path, mtime, mtime); + this.setTimes(path, mtime, mtime); if (auto attrs = am.fileAttributes) - std.file.setAttributes(path, attrs); + this.setAttributes(path, attrs); } // extract & place - ensureDirectory(destination); + this.ensureDirectory(destination); logDebug("Copying all files..."); int countFiles = 0; foreach(ArchiveMember a; archive.directory) { @@ -882,9 +882,9 @@ logDebug("Creating %s", cleanedPath); if (dst_path.endsWithSlash) { - ensureDirectory(dst_path); + this.ensureDirectory(dst_path); } else { - ensureDirectory(dst_path.parentPath); + this.ensureDirectory(dst_path.parentPath); // for symlinks on posix systems, use the symlink function to // create them. Windows default unzip doesn't handle symlinks, // so we don't need to worry about it for Windows. @@ -901,7 +901,7 @@ } this.writeFile(dst_path, archive.expand(a)); - setAttributes(dst_path.toNativeString(), a); + setAttributes(dst_path, a); symlink_exit: ++countFiles; } @@ -913,7 +913,7 @@ if (pack.recipePath.head != defaultPackageFilename) // Storeinfo saved a default file, this could be different to the file from the zip. - removeFile(pack.recipePath); + this.removeFile(pack.recipePath); pack.storeInfo(); addPackages(this.m_internal.localPackages, pack); return pack; @@ -953,6 +953,7 @@ enforce(found, "Cannot remove, package not found: '"~ pack.name ~"', path: " ~ to!string(pack.path)); logDebug("About to delete root folder for package '%s'.", pack.path); + import std.file : rmdirRecurse; rmdirRecurse(pack.path.toNativeString()); logInfo("Removed", Color.yellow, "%s %s", pack.name.color(Mode.bold), pack.version_); } @@ -1076,6 +1077,7 @@ /// .svn folders) Hash hashPackage(Package pack) { + import std.file; import dub.internal.vibecompat.core.file; string[] ignored_directories = [".git", ".dub", ".svn"]; @@ -1246,6 +1248,29 @@ static import dub.internal.vibecompat.core.file; return dub.internal.vibecompat.core.file.iterateDirectory(path); } + + /// Ditto + protected void removeFile(NativePath path) + { + static import dub.internal.vibecompat.core.file; + return dub.internal.vibecompat.core.file.removeFile(path); + } + + /// Ditto + protected void setTimes(in NativePath path, in SysTime accessTime, + in SysTime modificationTime) + { + static import std.file; + std.file.setTimes( + path.toNativeString(), accessTime, modificationTime); + } + + /// Ditto + protected void setAttributes(in NativePath path, uint attributes) + { + static import std.file; + std.file.setAttributes(path.toNativeString(), attributes); + } } deprecated(OverrideDepMsg) diff --git a/source/dub/test/base.d b/source/dub/test/base.d index a50a368..89c0624 100644 --- a/source/dub/test/base.d +++ b/source/dub/test/base.d @@ -384,15 +384,6 @@ ); } - // Re-introduce hidden/deprecated overloads - public alias store = PackageManager.store; - - /// Ditto - public override Package store(NativePath src, PlacementLocation dest, in PackageName name, in Version vers) - { - assert(0, "Function not implemented"); - } - /** * Re-Implementation of `gitClone`. * @@ -452,6 +443,12 @@ } /// + protected override void removeFile(NativePath path) + { + return this.fs.removeFile(path); + } + + /// protected override IterateDirDg iterateDirectory(NativePath path) { enforce(this.fs.existsDirectory(path), @@ -477,6 +474,19 @@ } return &iterator; } + + /// Ditto + protected override void setTimes(in NativePath path, in SysTime accessTime, + in SysTime modificationTime) + { + this.fs.setTimes(path, accessTime, modificationTime); + } + + /// Ditto + protected override void setAttributes(in NativePath path, uint attributes) + { + this.fs.setAttributes(path, attributes); + } } /**