diff --git a/uppsrc/ide/Core/Core.h b/uppsrc/ide/Core/Core.h index c1296d2c9..40177d840 100644 --- a/uppsrc/ide/Core/Core.h +++ b/uppsrc/ide/Core/Core.h @@ -215,6 +215,8 @@ inline String PackageDirectory(const String& name) { return GetFileDirectory(PackagePath(name)); } bool IsNestReadOnly(const String& path); +String GetPackagePathNest(const String& path); + String GetLocalDir(); String LocalPath(const String& filename); diff --git a/uppsrc/ide/Core/Workspace.cpp b/uppsrc/ide/Core/Workspace.cpp index 1f9c9d986..0ba8591ca 100644 --- a/uppsrc/ide/Core/Workspace.cpp +++ b/uppsrc/ide/Core/Workspace.cpp @@ -241,6 +241,15 @@ String PackagePath(const String& name) return MainNest().PackagePath(name); } +String GetPackagePathNest(const String& path) +{ + String h = UnixPath(NormalizePath(path)); + for(auto dir : GetUppDirs()) + if(h.StartsWith(UnixPath(NormalizePath(dir)) + '/')) + return dir; + return Null; +} + String SourcePath(const String& package, const String& file) { if(IsFullPath(file)) return NativePath(file); return NormalizePath(AppendFileName(GetFileFolder(PackagePath(package)), file)); diff --git a/uppsrc/ide/SelectPkg.cpp b/uppsrc/ide/SelectPkg.cpp index 7f3d3a876..aea829902 100644 --- a/uppsrc/ide/SelectPkg.cpp +++ b/uppsrc/ide/SelectPkg.cpp @@ -26,12 +26,13 @@ bool RenamePackageFs(const String& upp, const String& newname) return false; } String pf = GetFileFolder(upp); - String npf = GetFileFolder(pf) + "/" + newname; + String npf = GetPackagePathNest(pf) + "/" + newname; + RealizePath(npf); if(!FileMove(pf, npf)) { Exclamation("Renaming package folder has failed."); return false; } - if(!FileMove(npf + "/" + GetFileName(upp), npf + "/" + newname + ".upp")) { + if(!FileMove(npf + "/" + GetFileName(upp), npf + "/" + GetFileName(newname) + ".upp")) { FileMove(npf, pf); Exclamation("Renaming .upp file has failed."); return false; diff --git a/uppsrc/ide/UppWspc.cpp b/uppsrc/ide/UppWspc.cpp index 498282805..6824c3ece 100644 --- a/uppsrc/ide/UppWspc.cpp +++ b/uppsrc/ide/UppWspc.cpp @@ -977,19 +977,20 @@ void WorkspaceWork::PackageOp(String active, String from_package, String rename) from_package = UnixPath(from_package); rename = UnixPath(rename); for(int i = 0; i < package.GetCount(); i++) - if(IsNull(from_package) || UnixPath(package[i].name) == from_package) { + if(*package[i].name != '<' && + (IsNull(from_package) || UnixPath(package[i].name) == from_package)) { String pp = PackagePath(package[i].name); - RealizePath(pp); Package prj; - prj.Load(pp); - for(int i = prj.uses.GetCount(); --i >= 0;) - if(UnixPath(prj.uses[i].text) == active) { - if(rename.GetCount()) - prj.uses[i].text = rename; - else - prj.uses.Remove(i); - } - prj.Save(pp); + if(prj.Load(pp)) { + for(int i = prj.uses.GetCount(); --i >= 0;) + if(UnixPath(prj.uses[i].text) == active) { + if(rename.GetCount()) + prj.uses[i].text = rename; + else + prj.uses.Remove(i); + } + prj.Save(pp); + } } ScanWorkspace(); SyncWorkspace(); @@ -1024,9 +1025,10 @@ again: if(dlg.Execute() != IDOK) return; String pn = ~dlg.name; - if(!RenamePackageFs(GetActivePackage(), pn)) + String ap = GetActivePackage(); + if(!RenamePackageFs(PackagePath(ap), pn)) goto again; - PackageOp(GetActivePackage(), Null, pn); + PackageOp(ap, Null, pn); } void WorkspaceWork::DeletePackage()