root/OpenSceneGraph/trunk/examples/osgunittests/FileNameUtils.cpp @ 12292

Revision 12292, 3.1 kB (checked in by robert, 3 years ago)

Ran svn propset -R svn:eol-style native . on the OpenSceneGraph

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*-
2*
3*  OpenSceneGraph example, osgunittests.
4*
5*  Permission is hereby granted, free of charge, to any person obtaining a copy
6*  of this software and associated documentation files (the "Software"), to deal
7*  in the Software without restriction, including without limitation the rights
8*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9*  copies of the Software, and to permit persons to whom the Software is
10*  furnished to do so, subject to the following conditions:
11*
12*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18*  THE SOFTWARE.
19*/
20
21#include <osg/Notify>
22#include <osg/ArgumentParser>
23#include <osgDB/FileNameUtils>
24#include <list>
25
26void runFileNameUtilsTest(osg::ArgumentParser&)
27{
28typedef std::list<std::string> Strings;
29    Strings strings;
30    strings.push_back(std::string(""));
31    strings.push_back(std::string("myfile"));
32    strings.push_back(std::string(".osg"));
33    strings.push_back(std::string("myfile.osg"));
34    strings.push_back(std::string("/myfile.osg"));
35    strings.push_back(std::string("home/robert/myfile.osg"));
36    strings.push_back(std::string("/home/robert/myfile.osg"));
37    strings.push_back(std::string("\\myfile.osg"));
38    strings.push_back(std::string("home\\robert\\myfile.osg"));
39    strings.push_back(std::string("\\home\\robert\\myfile.osg"));
40    strings.push_back(std::string("\\home/robert\\myfile.osg"));
41    strings.push_back(std::string("\\home\\robert/myfile.osg"));
42    strings.push_back(std::string("home/robert/"));
43    strings.push_back(std::string("\\home\\robert\\"));
44    strings.push_back(std::string("home/robert/myfile"));
45    strings.push_back(std::string("\\home\\robert\\myfile"));
46    strings.push_back(std::string("home/robert/.osg"));
47    strings.push_back(std::string("\\home\\robert\\.osg"));
48    strings.push_back(std::string("home/robert/myfile.ext.osg"));
49    strings.push_back(std::string("home\\robert\\myfile.ext.osg"));
50
51    for(Strings::iterator itr = strings.begin();
52        itr != strings.end();
53        ++itr)
54    {
55        std::string& str = *itr;
56        OSG_NOTICE<<"string="<<str;
57        OSG_NOTICE<<"\n\tosgDB::getFilePath(str)="<<osgDB::getFilePath(str);
58        OSG_NOTICE<<"\n\tosgDB::getSimpleFileName(str)="<<osgDB::getSimpleFileName(str);
59        OSG_NOTICE<<"\n\tosgDB::getStrippedName(str)="<<osgDB::getStrippedName(str);
60        OSG_NOTICE<<"\n\tosgDB::getFileExtension(str)="<<osgDB::getFileExtension(str);
61        OSG_NOTICE<<"\n\tosgDB::getFileExtensionIncludingDot(str)="<<osgDB::getFileExtensionIncludingDot(str);
62        OSG_NOTICE<<"\n\tosgDB::getNameLessExtension(str)="<<osgDB::getNameLessExtension(str);
63        OSG_NOTICE<<"\n\tosgDB::getNameLessAllExtensions(str)="<<osgDB::getNameLessAllExtensions(str);
64        OSG_NOTICE<<std::endl<<std::endl;
65    }
66}
Note: See TracBrowser for help on using the browser.