// // DemoAndLicensing_Test.cpp // // Created by Andrew Salamon on 12/14/07. // Copyright 2007 Machine Perception Laboratory, University of California San Diego. All rights reserved. #include "DemoAndLicensing_Test.h" #include #include // For system independent path support #include #include #include // For basename and extension namespace bf = boost::filesystem; namespace CERT { DemoAndLicensing_Test::DemoAndLicensing_Test() { } DemoAndLicensing_Test::~DemoAndLicensing_Test() { } bool DemoAndLicensing_Test::readDemoStartDate() { return DemoAndLicensing::readDemoStartDate(); } bool DemoAndLicensing_Test::writeDemoStartDate() { return DemoAndLicensing::writeDemoStartDate(); } bool DemoAndLicensing_Test::writeGivenDate( const bg::date &aDate ) { tm myTM = to_tm( aDate ); time_t dt = mktime( &myTM ); return DemoAndLicensing::writeDemoStartDate( dt ); } bool DemoAndLicensing_Test::clearPaths() { std::vector paths = getAllowedPaths(); bf::path fname( getFilename(), bf::native ); for( std::vector::iterator iter = paths.begin(); iter != paths.end(); ++iter ) { bf::path dir( *iter, bf::native ); bf::path bfPath = dir / fname; if( bf::exists( bfPath ) && !bf::remove( bfPath ) ) return false; if( bfPath.has_branch_path() ) { bfPath = bfPath.branch_path(); if( bf::exists( bfPath ) && !bf::remove( bfPath ) ) return false; } } return true; } bool DemoAndLicensing_Test::blockPaths() { std::vector paths = getAllowedPaths(); bf::path fname( getFilename(), bf::native ); for( std::vector::iterator iter = paths.begin(); iter != paths.end(); ++iter ) { bf::path dir( *iter, bf::native ); bf::path bfPath = dir / fname; if( !bf::create_directories( bfPath ) ) return false; } return true; } bool DemoAndLicensing_Test::createDirectories() { std::vector paths = getAllowedPaths(); for( std::vector::iterator iter = paths.begin(); iter != paths.end(); ++iter ) { bf::path dir( *iter, bf::native ); if( !bf::create_directories( dir ) ) { return false; } if( !bf::exists( dir ) || !bf::is_directory( dir ) ) return false; } return true; } } // end namespace CERT