mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
moved test sources to test directory and deleted a few dead files , created new util test directory.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3396 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
dc7dd949ca
commit
9e86265f91
8 changed files with 0 additions and 239 deletions
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* dirtest.cc
|
||||
*
|
||||
* RetroShare Test Program.
|
||||
*
|
||||
* Copyright 2004-2007 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int processpath(std::string path);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
std::string path1 = "/home/tst1//test2///test3/";
|
||||
std::string path2 = "home2/tst4//test5///test6";
|
||||
std::string path3 = "//home3";
|
||||
std::string path4 = "//";
|
||||
std::string path5 = "/a/b/c/d/";
|
||||
std::string path6 = "a//b/c//d";
|
||||
|
||||
processpath(path1);
|
||||
processpath(path2);
|
||||
processpath(path3);
|
||||
processpath(path4);
|
||||
processpath(path5);
|
||||
processpath(path6);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int processpath(std::string path)
|
||||
{
|
||||
std::string pathtogo = path;
|
||||
while(pathtogo != "")
|
||||
{
|
||||
std::string basedir = RsDirUtil::getRootDir(pathtogo);
|
||||
std::string rempath = RsDirUtil::removeRootDir(pathtogo);
|
||||
std::string topdir = RsDirUtil::getTopDir(pathtogo);
|
||||
std::string remtoppath = RsDirUtil::removeTopDir(pathtogo);
|
||||
|
||||
std::cerr << "Processing: \"" << pathtogo << "\"" << std::endl;
|
||||
std::cerr << "\tRootDir : \"" << basedir << "\"" << std::endl;
|
||||
std::cerr << "\tRemaining: \"" << rempath << "\"" << std::endl;
|
||||
std::cerr << "\tTopDir : \"" << topdir << "\"" << std::endl;
|
||||
std::cerr << "\tRemaining(Top): \"" << remtoppath << "\"" << std::endl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
pathtogo = rempath;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
|
||||
/*
|
||||
* "$Id: dirtest.cc,v 1.1 2007-02-19 20:08:30 rmf24 Exp $"
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2004-2007 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
bool testRsDirUtils(std::string path);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
std::list<std::string> dirs;
|
||||
std::list<std::string>::iterator it;
|
||||
dirs.push_back("/incoming/htuyr/file.txt");
|
||||
dirs.push_back("/incoming/htuyr/file.txt ");
|
||||
dirs.push_back("/incoming/htuyr/file.txt/");
|
||||
dirs.push_back("/incoming/htuyr/file.txt//");
|
||||
dirs.push_back("/incoming/htuyr//file.txt//");
|
||||
dirs.push_back("/incoming/htuyr//file .txt");
|
||||
dirs.push_back("/incoming/htuyr/Q");
|
||||
dirs.push_back("/incoming/htuyr/Q//");
|
||||
dirs.push_back("/incoming/htuyr/Q/");
|
||||
dirs.push_back("/incoming/htuyr/Q/text");
|
||||
dirs.push_back("/home/tst1//test2///test3/");
|
||||
dirs.push_back("home2/tst4//test5///test6");
|
||||
dirs.push_back("//home3");
|
||||
dirs.push_back("//");
|
||||
dirs.push_back("A");
|
||||
dirs.push_back("ABC");
|
||||
dirs.push_back("////ABC////");
|
||||
dirs.push_back("A/B/C");
|
||||
|
||||
for(it = dirs.begin(); it != dirs.end(); it++)
|
||||
{
|
||||
testRsDirUtils(*it);
|
||||
}
|
||||
}
|
||||
|
||||
bool testRsDirUtils(std::string path)
|
||||
{
|
||||
|
||||
std::cerr << "RsUtilTest input: [" << path << "]";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::string top = RsDirUtil::getTopDir(path);
|
||||
std::string root = RsDirUtil::getRootDir(path);
|
||||
std::string topdirs = RsDirUtil::removeRootDir(path);
|
||||
std::string topdirs2 = RsDirUtil::removeRootDirs(path, root);
|
||||
std::string restdirs = RsDirUtil::removeTopDir(path);
|
||||
std::list<std::string> split;
|
||||
std::list<std::string>::iterator it;
|
||||
RsDirUtil::breakupDirList(path, split);
|
||||
|
||||
std::cerr << "\tTop: [" << top << "]";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\tRest: [" << restdirs << "]";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::cerr << "\tRoot: [" << root << "]";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\tRemoveRoot: [" << topdirs << "]";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\tSplit Up ";
|
||||
for(it = split.begin(); it != split.end(); it++)
|
||||
{
|
||||
std::cerr << ":" << (*it);
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
std::cerr << std::endl;
|
||||
return true;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue