#include "UnixFile.hpp"
#include "StringUtils.hpp"

#include <unistd.h>
#include <iostream>
using namespace std;

int main( int argc, char** args) {
  cout << "Debug Program for class UnixFile. (c) 2001 Michael Weers" << endl
       ;

  UnixFile* f= new UnixFile( args[1], UnixFile::AS_IS);
  
  cout << "Fullname: " << f->getFullName() << endl;
  cout << "Name:     " << f->getName() << "\n";
  cout << "Parent:   " << f->getParent() << "\n";
  cout << "internal state: " << f->state << endl;
  cout << "Size:     " << f->getSize() << "\n";
  cout << f->getAttributeString() << "\n";

  cout << "exists(): " << f->exists() << endl;
  
  
  cout << "Linked Directory is a SubNavigable:" << f->isSubNavigable() << endl;
  
  StringTokenizer st( f->getFullName(), "/");
  while( st.hasMoreTokens())
    cout << "|" << st.getNextToken() << "|" << endl;
//  cout << f->linkedFile << endl << endl;
  
  cout << "Checking access for calling user:" << endl
       << "Read:           " << (access( f->getFullName().c_str(), R_OK) == 0 ? "yes" : "no") << endl
       << "Write:          " << (access( f->getFullName().c_str(), W_OK) == 0 ? "yes" : "no") << endl
       << "Execute:        " << (access( f->getFullName().c_str(), X_OK) == 0 ? "yes" : "no") << endl
       << "Check Existence:" << (access( f->getFullName().c_str(), F_OK) == 0 ? "yes" : "no") << endl;


  cout << "startWith() test [1]: " << startsWith( "abc", "abc") << endl;

 
  return 0;
}
