[yast-devel] Re: [yast-commit] r65499 - in /branches/SuSE-Code-11-SP2-Branch/yast2: ./ library/types/src/ library/types/testsuite/tests/ package/
On Thursday 01 of September 2011 14:06:13 lslezak@svn2.opensuse.org wrote:
Author: lslezak Date: Thu Sep 1 14:06:13 2011 New Revision: 65499
URL: http://svn.opensuse.org/viewcvs/yast?rev=65499&view=rev Log: - added String::FindMountPoint() function (moved from yast2-wagon to share it with yast2-packager)
The String module does not sound right for this function. Yes, the implementation is prefix matching of strings, but either name it so (as it's generic functionality), or move it to a different module related to Storage (?) Stano
- 2.17.110
Added:
branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.err branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.out branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.ycp Modified: branches/SuSE-Code-11-SP2-Branch/yast2/VERSION branches/SuSE-Code-11-SP2-Branch/yast2/library/types/src/String.ycp branches/SuSE-Code-11-SP2-Branch/yast2/package/yast2.changes
Modified: branches/SuSE-Code-11-SP2-Branch/yast2/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast 2/VERSION?rev=65499&r1=65498&r2=65499&view=diff ========================================================================== ==== --- branches/SuSE-Code-11-SP2-Branch/yast2/VERSION (original) +++ branches/SuSE-Code-11-SP2-Branch/yast2/VERSION Thu Sep 1 14:06:13 2011 @@ -1 +1 @@ -2.17.109 +2.17.110
Modified: branches/SuSE-Code-11-SP2-Branch/yast2/library/types/src/String.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast 2/library/types/src/String.ycp?rev=65499&r1=65498&r2=65499&view=diff ========================================================================== ==== --- branches/SuSE-Code-11-SP2-Branch/yast2/library/types/src/String.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/yast2/library/types/src/String.ycp Thu Sep 1 14:06:13 2011 @@ -1250,5 +1250,29 @@ return search(str, test) == 0; }
+/* +* Find a mount point for given directory/file path. Returns "/" if no mount point matches +* @param dir requested path , e.g. "/usr/share" +* @param dirs list of mount points, e.g. [ "/", "/usr", "/boot" ] +* @return string a mount point from the input list or "/" if not found +*/ +global string FindMountPoint(string dir, list<string> dirs) +{ + while (dir != nil && dir != "" && !contains(dirs, dir)) + { + // strip the last path component and try it again + list<string> comps = splitstring(dir, "/"); + comps = remove(comps, size(comps) - 1); + dir = mergestring(comps, "/"); + } + + if (dir == nil || dir == "") + { + dir = "/"; + } + + return dir; +} + /* EOF */ }
Added: branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.err URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast 2/library/types/testsuite/tests/FindMountPoint.err?rev=65499&view=auto ========================================================================== ==== (empty)
Added: branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.out URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast 2/library/types/testsuite/tests/FindMountPoint.out?rev=65499&view=auto ========================================================================== ==== --- branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.out (added) +++ branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.out Thu Sep 1 14:06:13 2011 @@ -0,0 +1,14 @@ +Dump Test nil +Return / +Return / +Return / +Dump Test empty string +Return / +Return / +Return / +Dump Test valid values +Return / +Return /usr +Return /usr +Return /usr +Return /usr/share
Added: branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast 2/library/types/testsuite/tests/FindMountPoint.ycp?rev=65499&view=auto ========================================================================== ==== --- branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.ycp (added) +++ branches/SuSE-Code-11-SP2-Branch/yast2/library/types/testsuite/tests/FindM ountPoint.ycp Thu Sep 1 14:06:13 2011 @@ -0,0 +1,24 @@ +{ + +include "testsuite.ycp"; + +import "String"; + +//import "Wagon"; +DUMP("Test nil"); +TEST(``(String::FindMountPoint(nil, nil)), [], nil); +TEST(``(String::FindMountPoint(nil, [])), [], nil); +TEST(``(String::FindMountPoint(nil, ["/boot", "/"])), [], nil); + +DUMP("Test empty string"); +TEST(``(String::FindMountPoint("", nil)), [], nil); +TEST(``(String::FindMountPoint("", [])), [], nil); +TEST(``(String::FindMountPoint("", ["/boot", "/"])), [], nil); + +DUMP("Test valid values"); +TEST(``(String::FindMountPoint("/", ["/boot", "/", "/usr"])), [], nil); +TEST(``(String::FindMountPoint("/usr", ["/boot", "/", "/usr"])), [], nil); +TEST(``(String::FindMountPoint("/usr/", ["/boot", "/", "/usr"])), [], nil); +TEST(``(String::FindMountPoint("/usr/share/locale", ["/boot", "/", "/usr"])), [], nil); +TEST(``(String::FindMountPoint("/usr/share/locale", ["/boot", "/", "/usr", "/usr/share"])), [], nil); +}
Modified: branches/SuSE-Code-11-SP2-Branch/yast2/package/yast2.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast 2/package/yast2.changes?rev=65499&r1=65498&r2=65499&view=diff ========================================================================== ==== --- branches/SuSE-Code-11-SP2-Branch/yast2/package/yast2.changes (original) +++ branches/SuSE-Code-11-SP2-Branch/yast2/package/yast2.changes Thu Sep 1 14:06:13 2011 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Thu Sep 1 11:33:18 UTC 2011 - lslezak@suse.cz + +- added String::FindMountPoint() function (moved from yast2-wagon + to share it with yast2-packager) +- 2.17.110 + +------------------------------------------------------------------- Thu Sep 1 06:40:43 UTC 2011 - jsrain@site
- enhanced the help command-line parameters (bnc#712271) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (1)
-
Stanislav Visnovsky