Treatment of paths in Resource_Manager is corrected to handle properly paths with dots inside.
Extraction of extension from path in DOS mode when working on Linux is corrected in OSD_Path.
Test case added.
buffer.Remove(1,disk.Length()); // Removes <<disk:>>
}
- if (buffer.Search(".") != -1){ // There is an extension to extract
- ext = buffer.Token(".",2);
- ext.Insert(1,'.'); // Prepends 'dot'
- pos = buffer.Search("."); // Removes extension from buffer
- if (pos != -1)
- buffer.Remove(pos,ext.Length());
- }
-
trek = buffer;
- trek.ChangeAll('\\','|');
+ trek.ChangeAll('\\','|');
pos = trek.Search("..");
while (pos != -1){ // Changes every ".." by '^'
pos = trek.Search("..");
}
- pos = trek.SearchFromEnd("|"); // Extract name
+ pos = trek.SearchFromEnd ("|"); // Extract name
if (pos != -1) {
- p = (Standard_PCharacter)trek.ToCString();
- name = &p[pos];
- trek.Remove(trek.Search(name),name.Length());
+ p = (Standard_PCharacter)trek.ToCString ();
+ name = &p[pos];
+ if (name.Length ()) trek.Remove (pos + 1, name.Length ());
}
else { // No '|' means no trek but a name
- name = buffer;
- trek = "";
+ name = buffer;
+ trek = "";
}
+
+ pos = name.SearchFromEnd (".");
+ if (pos != -1) // There is an extension to extract
+ ext = name.Split (pos - 1);
}
return 0;
}
+static Standard_Integer OCC27849 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+ if (argc != 3) {
+ di << "Usage : " << argv[0] << " <environment variable name> <resource name>\n";
+ return 1;
+ }
+ Standard_CString aEnvName = argv[1];
+ Standard_CString aResName = argv[2];
+
+ Resource_Manager aManager (aEnvName);
+ if (aManager.Find (aResName))
+ {
+ di << aManager.Value (aResName);
+ }
+ else
+ {
+ di << "Error: could not find resource " << aResName;
+ }
+
+ return 0;
+}
+
static Standard_Real delta_percent (Standard_Real a, Standard_Real b)
{
Standard_Real result;
theCommands.Add("OCC267", "OCC267 DOC path", __FILE__, OCC267, group);
theCommands.Add("OCC181", "OCC181 FileName path1 path2 verbose=0/1", __FILE__, OCC181, group);
+ theCommands.Add("OCC27849", "OCC27849 <resource env name> <resource name>", __FILE__, OCC27849, group);
theCommands.Add("OCC367", "OCC367 shape step goodX goodY goodZ percent_tolerance", __FILE__, OCC367, group);
return;
{
if ( !aDefaultsDirectory.IsEmpty() ) {
OSD_Path anOSDPath(aDefaultsDirectory);
- anOSDPath.DownTrek(anOSDPath.Name());
+ if (!anOSDPath.Name().IsEmpty())
+ {
+ anOSDPath.DownTrek (anOSDPath.Name () + anOSDPath.Extension ());
+ }
anOSDPath.SetName(aName);
+ anOSDPath.SetExtension("");
TCollection_AsciiString aPath;
anOSDPath.SystemName(aPath);
Load(aPath,myRefMap);
if ( !anUserDefaultsDirectory.IsEmpty() ) {
OSD_Path anOSDPath(anUserDefaultsDirectory);
- anOSDPath.DownTrek(anOSDPath.Name());
+ if (!anOSDPath.Name().IsEmpty())
+ {
+ anOSDPath.DownTrek (anOSDPath.Name () + anOSDPath.Extension ());
+ }
anOSDPath.SetName(aName);
+ anOSDPath.SetExtension("");
TCollection_AsciiString aPath;
anOSDPath.SystemName(aPath);
Load(aPath,myRefMap);
}
}
- anOSDPath.DownTrek(anOSDPath.Name());
+ if (!anOSDPath.Name().IsEmpty())
+ {
+ anOSDPath.DownTrek (anOSDPath.Name () + anOSDPath.Extension ());
+ }
anOSDPath.SetName(myName);
+ anOSDPath.SetExtension("");
anOSDPath.SystemName(aFilePath);
OSD_File File = anOSDPath;
if (!anOSDPath.Name().IsEmpty())
{
- anOSDPath.DownTrek(anOSDPath.Name());
+ anOSDPath.DownTrek (anOSDPath.Name () + anOSDPath.Extension ());
}
-
- anOSDPath.SetName(aName);
+ anOSDPath.SetName (aName);
+ anOSDPath.SetExtension ("");
anOSDPath.SystemName(aPath);
}
--- /dev/null
+puts "Test loading of resources from different paths"
+puts "0027849: ResourceManager path computations fail for the folders containing dots"
+
+pload QAcommands
+
+
+set paths {
+ "path"
+ "path.with.dots"
+ "path with spaces"
+ "nested/dirs/path with spaces"
+}
+
+# key word to be saved in resource file and then checked
+set keyw ok
+
+foreach p $paths {
+ set path [file join $imagedir $p]
+
+ file mkdir $path
+
+ set fd [open $path/TestResource w]
+ puts $fd "test.resource : $keyw"
+ close $fd
+
+
+ dsetenv CSF_TestResourceDefaults $path
+
+ if { [OCC27849 TestResource test.resource] != "$keyw" } {
+ puts "Error: cannot read resource file in $path"
+ }
+}