#include "strfnd.h"
#include <iostream>
#include <string.h>
+#include "log.h"
namespace fs
{
if( DirSpec == NULL )
{
- printf( "Insufficient memory available\n" );
+ errorstream<<"GetDirListing: Insufficient memory available"<<std::endl;
retval = 1;
goto Cleanup;
}
// Check that the input is not larger than allowed.
if (pathstring.size() > (BUFSIZE - 2))
{
- _tprintf(TEXT("Input directory is too large.\n"));
+ errorstream<<"GetDirListing: Input directory is too large."<<std::endl;
retval = 3;
goto Cleanup;
}
if (hFind == INVALID_HANDLE_VALUE)
{
- _tprintf (TEXT("Invalid file handle. Error is %u.\n"),
- GetLastError());
+ errorstream<<"GetDirListing: Invalid file handle. Error is "
+ <<GetLastError()<<std::endl;
retval = (-1);
}
else
FindClose(hFind);
if (dwError != ERROR_NO_MORE_FILES)
{
- _tprintf (TEXT("FindNextFile error. Error is %u.\n"),
- dwError);
- retval = (-1);
- goto Cleanup;
+ errorstream<<"GetDirListing: FindNextFile error. Error is "
+ <<dwError<<std::endl;
+ retval = (-1);
+ goto Cleanup;
}
}
retval = 0;
if(retval != 0) listing.clear();
//for(unsigned int i=0; i<listing.size(); i++){
- // std::cout<<listing[i].name<<(listing[i].dir?" (dir)":" (file)")<<std::endl;
+ // infostream<<listing[i].name<<(listing[i].dir?" (dir)":" (file)")<<std::endl;
//}
return listing;
bool RecursiveDelete(std::string path)
{
- std::cerr<<"Removing \""<<path<<"\""<<std::endl;
+ infostream<<"Removing \""<<path<<"\""<<std::endl;
//return false;
int r = SHFileOperation(&sfo);
if(r != 0)
- std::cerr<<"SHFileOperation returned "<<r<<std::endl;
+ errorstream<<"SHFileOperation returned "<<r<<std::endl;
//return (r == 0);
return true;
DIR *dp;
struct dirent *dirp;
if((dp = opendir(pathstring.c_str())) == NULL) {
- //std::cout<<"Error("<<errno<<") opening "<<pathstring<<std::endl;
+ //infostream<<"Error("<<errno<<") opening "<<pathstring<<std::endl;
return listing;
}
Execute the 'rm' command directly, by fork() and execve()
*/
- std::cerr<<"Removing \""<<path<<"\""<<std::endl;
+ infostream<<"Removing \""<<path<<"\""<<std::endl;
//return false;
argv[2] = argv_data[2];
argv[3] = NULL;
- std::cerr<<"Executing '"<<argv[0]<<"' '"<<argv[1]<<"' '"
+ verbosestream<<"Executing '"<<argv[0]<<"' '"<<argv[1]<<"' '"
<<argv[2]<<"'"<<std::endl;
execv(argv[0], argv);
bool RecursiveDeleteContent(std::string path)
{
- std::cerr<<"Removing content of \""<<path<<"\""<<std::endl;
+ infostream<<"Removing content of \""<<path<<"\""<<std::endl;
std::vector<DirListNode> list = GetDirListing(path);
for(unsigned int i=0; i<list.size(); i++)
{
bool r = RecursiveDelete(childpath);
if(r == false)
{
- std::cerr<<"Removing \""<<childpath<<"\" failed"<<std::endl;
+ errorstream<<"Removing \""<<childpath<<"\" failed"<<std::endl;
return false;
}
}