Esempio n. 1
1
    void newProfile( const std::string& profile )
    {
        _mkdir( ( "profiles/"+profile ).c_str() );
        _mkdir( ( "profiles/"+profile + "/save" ).c_str() );
        _mkdir( ( "profiles/"+profile + "/config" ).c_str() );

        // should copy the default keybinds to the
        // profiles/"profile"/config/
#ifdef LEGACY_FILES
        copyFile( "Data/Misc/keybinds.txt", "profiles/"+profile+"/config/keybinds.txt" );
#else
        copyFile( "data/misc/default_keybinds.txt", "profiles/"+profile+"/config/keybinds.txt" );
#endif

    }
Esempio n. 2
0
QString KTheme::processFilePath( const QString & section, const QString & path )
{
    QFileInfo fi( path );

    if ( fi.isRelative() )
        fi.setFile( findResource( section, path ) );

    kdDebug() << "Processing file: " << fi.absFilePath() << ", " << fi.fileName() << endl;

    if ( section == "desktop" )
    {
        if ( copyFile( fi.absFilePath(), m_kgd->saveLocation( "themes", m_name + "/wallpapers/desktop/" ) + "/" + fi.fileName() ) )
            return "theme:/wallpapers/desktop/" + fi.fileName();
    }
    else if ( section == "sounds" )
    {
        if ( copyFile( fi.absFilePath(), m_kgd->saveLocation( "themes", m_name + "/sounds/" ) + "/" + fi.fileName() ) )
            return "theme:/sounds/" + fi.fileName();
    }
    else if ( section == "konqueror" )
    {
        if ( copyFile( fi.absFilePath(), m_kgd->saveLocation( "themes", m_name + "/wallpapers/konqueror/" ) + "/" + fi.fileName() ) )
            return "theme:/wallpapers/konqueror/" + fi.fileName();
    }
    else if ( section == "panel" )
    {
        if ( copyFile( fi.absFilePath(), m_kgd->saveLocation( "themes", m_name + "/wallpapers/panel/" ) + "/" + fi.fileName() ) )
            return "theme:/wallpapers/panel/" + fi.fileName();
    }
    else
        kdWarning() << "Unsupported theme resource type" << endl;

    return QString::null;       // an error occured or the resource doesn't exist
}
void MeshSerializerTests::tearDown()
{

	// Copy back original file.
	if (!mMeshFullPath.empty()) {
		copyFile(mMeshFullPath + ".bak", mMeshFullPath);
	}
	if (!mSkeletonFullPath.empty()) {
		copyFile(mSkeletonFullPath + ".bak", mSkeletonFullPath);
	}
	if (!mMesh.isNull()) {
		mMesh->unload();
		mMesh.setNull();
	}
	if (!mOrigMesh.isNull()) {
		mOrigMesh->unload();
		mOrigMesh.setNull();
	}
	if (!mSkeleton.isNull()) {
		mSkeleton->unload();
		mSkeleton.setNull();
	}
	OGRE_DELETE MeshManager::getSingletonPtr();
	OGRE_DELETE SkeletonManager::getSingletonPtr();
	OGRE_DELETE DefaultHardwareBufferManager::getSingletonPtr();
	OGRE_DELETE ArchiveManager::getSingletonPtr();
	OGRE_DELETE MaterialManager::getSingletonPtr();
	OGRE_DELETE LodStrategyManager::getSingletonPtr();
	OGRE_DELETE ResourceGroupManager::getSingletonPtr();
	OGRE_DELETE_T(mFSLayer, FileSystemLayer, Ogre::MEMCATEGORY_GENERAL);
	OGRE_DELETE mLogManager;
}
Esempio n. 4
0
int main() {
	char *charv = "This is a test string.";
	//strlen is from string.h - it returns the length of a char or char*
	int charv_length = strlen(charv);
	//char* resultString;	// will result in segfault because size of variable is unknown
							//and it cannot be inserted into string or strcat'ed
	
	char resultString[255]; //perfectly valid 
	
	//%i %c %s tokens are int, char, and char* respectively
	//sprintf will create strings instead of printing to stdout
	sprintf(resultString, "Variable: \"%s\" is %i characters long!", charv, charv_length);
	
	printf("\n%s", resultString);
	
	//if comparisons result in either 0 or 1, without a test operand, 1 is true
	if (fileExists_ACCESS(FILENAME)) printf("\nFile %s Exists!\n", FILENAME);
	else printf("File %s Does not exist!\n", FILENAME);
	
	copyFile(FILENAME,"file2");
	
	if (!copyFile(FILENAME,"file2")) printf("file copied!\n"); //if the result of copyFile() is not 1
		
	return 0;
}
Esempio n. 5
0
long CA_Init(void)
{
	FILE * cafile;
	char   capath[256];

	sprintf(capath, "%s%s\\CaFile.data", ddbsdk.ddbsdk_path_main, DDBSDK_MAINPATH_NAME);
	//if((cafile = fopen(capath, "rb")) == NULL) {
	if((cafile = fopen("softcard.ca", "rb")) == NULL) {
		if (1 <= copyFile("\\NANDFlash\\softcard.ca", "\\Flash_Storage\\softcard.ca"))
		{
			printf("CA文件还原失败!\n");
			return -1;
		}
		if((cafile = fopen("softcard.ca", "rb")) == NULL) 
		{
			printf("CA文件无法打开!\n");
			return -1;
		}

	}

	printf("CA文件成功打开!\n");
	
	g_BufferForCAS = (BYTE *)malloc(FOR_CAS_DATA_BUFFER_SIZE);
	memset(g_BufferForCAS, 0, FOR_CAS_DATA_BUFFER_SIZE);
	fread(g_BufferForCAS, 1, FOR_CAS_DATA_BUFFER_SIZE, cafile);
	fclose(cafile);
	if(!DVTCASTB_Init())
	{
		printf("CA初始化失败!\n");
		printf("尝试还原CA文件\n");
		if (1 <= copyFile("\\NANDFlash\\softcard.ca", "\\Flash_Storage\\softcard.ca"))
		{
			printf("CA文件还原失败!\n");
			free(g_BufferForCAS);
			return -1;
		}
		if((cafile = fopen("softcard.ca", "rb")) == NULL) 
		{
			printf("CA文件无法打开!\n");
			free(g_BufferForCAS);
			return -1;
		}
		fread(g_BufferForCAS, 1, FOR_CAS_DATA_BUFFER_SIZE, cafile);
		fclose(cafile);
		if(!DVTCASTB_Init())
		{
			printf("CA初始化失败!\n");
			free(g_BufferForCAS);
			return -1;
		}
	}

	printf("CA初始化成功!\n");

	return 0;
}
Esempio n. 6
0
void prepareMsiData(int localeId) {
  String msiFilePath = getTmpPath() + kMsiFileName;
  // Copy msi file to temp
  copyFile(IDR_MSI, msiFilePath);
  
  // Don't need transform for English (United States)
  if (localeId != kEnglishLocalId) {
    String transformFile = createFileName(localeId);
    String transformFilePath = getTmpPath() + transformFile;
    // Copy mst file to temp if needed
    copyFile(localeId, transformFilePath);
  }
}
Esempio n. 7
0
bool CShop::LoadConfig()
{

  char* fileName = "ShopItem.txt";
  if (!IsFileExist(fileName, TXT_PATH))
    copyFile(fileName, TXT_PATH);
  string fullFilePath = getFilePath(fileName, TXT_PATH);
  int fileLen = strlen(fullFilePath.c_str());
  if (!fileLen)
    return false;
  char buffer[256];  
  ifstream in(fullFilePath);  
  if (! in.is_open())  
  { 
    cout << "Error opening file ShopItem"; 
    return false; 
  }
  int Line = 0;
  while (EOF != in.peek() )  
  { 
    in.getline (buffer,256);
    GParse GP(buffer);
    ShopData Item;
    Item.Id = GP.getInt();
    Item.money = GP.getInt();
    _ShopDatas.push_back(Item);
  }
  return true;
}
Esempio n. 8
0
bool CPropertySet::LoadConfig()
{
#ifdef _FILESYSTEM
  char* fileName = "PropertySet.txt";
  if (!IsFileExist(fileName, TXT_PATH))
    copyFile(fileName, TXT_PATH);
  string fullFilePath = getFilePath(fileName, TXT_PATH);
  int fileLen = strlen(fullFilePath.c_str());
  if (!fileLen)
    return false;
  char buffer[256];  
  ifstream in(fullFilePath);  
  if (! in.is_open())  
  { 
    cout << "Error opening file PropertySet"; 
    return false; 
  }
  int Line = 0;
  while (EOF != in.peek() )  
  { 
    in.getline (buffer,256);
    GParse GP(buffer);
    PropertySet Item;
    Item.Idx = GP.getInt();
    Item.Id = GP.getInt();
    PropertySets.push_back(Item);
  }
  return true;
#endif // _FILESYSTEM

  return true;
}
Esempio n. 9
0
pwr_tStatus
wb_dbs::writeReferencedVolumes()
{
  pwr_tStatus sts;      

  // Search trhough all found volumes and get their volrefs
  sVentry *vep;
  vep = (sVentry*)tree_Minimum(&sts, m_vol_th);
  while (vep) {
    if (vep->env.file.cookie == 0) {
      printf("  volume not found: %d\n", vep->v.vid);
    } else {
      if (fseek(m_fp, vep->v.offset, SEEK_SET) != 0)
        return LDH__FILEPOS;
      if (fseek(vep->env.f, 0, SEEK_SET) != 0)
        return LDH__FILEPOS;

      sts = copyFile(vep->env.f, m_fp, vep->env.file.size);
      if (EVEN(sts))
        return LDH__FILEWRITE;

      assert(ftell(m_fp) == (long)(vep->v.offset + vep->env.file.size));
    }

    vep = (sVentry*)tree_Successor(&sts, m_vol_th, vep);        
  }

  return LDH__SUCCESS;
}
Esempio n. 10
0
/**
 * Copies target path and all children to destination path.
 *
 * Returns 0 on success or a negative value indicating number of failures
 */
int copyRecursive(const char *fromPath, const char *toPath) {
    int ret = 0;
    string fromPathStr(fromPath);
    string toPathStr(toPath);

    DIR* dir = opendir(fromPath);
    if (!dir) {
        PLOG(ERROR) << "opendir " << fromPath << " failed";
        return -1;
    }
    if (fromPathStr[fromPathStr.size()-1] != '/')
        fromPathStr += '/';
    if (toPathStr[toPathStr.size()-1] != '/')
        toPathStr += '/';

    struct dirent* entry;
    while ((entry = readdir(dir))) {
        const char* name = entry->d_name;

        // ignore "." and ".."
        if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) {
            continue;
        }
        string oldFile = fromPathStr + name;
        string newFile = toPathStr + name;

        if (entry->d_type == DT_DIR) {
            ret += makeFolder(newFile.c_str());
            ret += copyRecursive(oldFile.c_str(), newFile.c_str());
        } else {
            ret += copyFile(oldFile.c_str(), newFile.c_str());
        }
    }
    return ret;
}
Esempio n. 11
0
int main(int argc, char *argv[]) {
    char *source_file;
    char *new_file;

    // Program calistirilirken verilen argumanların dogru sekilde
    // olup olmadigi kontrolu yapilmaktadir. Eger argumanlar dogru
    // sekilde verildiyse, kaynak dosya ve yeni dosya bilgisi ilgili
    // degiskenlere atanir.
    if (argc == 3) {
        source_file = argv[1];
        new_file = argv[2];
    }

    // Argumanlar hatali bir sekilde verilmisse ekrana dogru sekli yazdirilir.
    else {
        printf("Programi yanlis sekilde calistirdiniz.\n");
        printf("Dogrusu su sekilde olmalidir: ./kopyala /dirx/../kaynak_dosya /diry/../yeni_dosya\n");
        exit(1);
    }


    // Kopyalama isleminin 2 saniyeden uzun surmesi durumunda ekranda bilgi
    // mesaji gosterilmesi icin bir signal olusturulur ve alarm 2 saniyeye
    // ayarlanir.
    signal(SIGALRM, display_message);
    alarm(2);


    // Kopyalama islemi baslatilir.
    copyFile(source_file, new_file);


    alarm(0);
    return 0;
}
Esempio n. 12
0
axStatus	axFileSystem::copyDir	( const char* src, const char* dst, bool skipFileStartsWithDot ) {
	axStatus st;

	axDir::Entry e;
	axTempStringA src_file, dst_file;

	axDir dir;
	st = dir.open( src ); if( !st ) return st;

	_makeDir( dst );

	while( dir.next( e ) ) {
		if( skipFileStartsWithDot ) {
			if( e.name.startsWith(".") ) continue;
		}
		if( e.name.equals(".")  ) continue;
		if( e.name.equals("..") ) continue;

		st = src_file.format("{?}/{?}", src, e.name );	if( !st ) return st;
		st = dst_file.format("{?}/{?}", dst, e.name );	if( !st ) return st;

		if( e.isDir() ) {
			st = copyDir ( src_file, dst_file, skipFileStartsWithDot ); if( !st ) return st;
		}else {
			st = copyFile( src_file, dst_file ); if( !st ) return st;
		}

	}

	return 0;
}
Esempio n. 13
0
	string perform(const shared_ptr< const Config >& /* config */, const download::Uri& uri,
			const string& targetPath, const std::function< void (const vector< string >&) >& callback)
	{
		auto sourcePath = uri.getOpaque();
		auto protocol = uri.getProtocol();

		// preparing source
		string openError;
		File sourceFile(sourcePath, "r", openError);
		if (!openError.empty())
		{
			return format2("unable to open the file '%s' for reading: %s", sourcePath, openError);
		}

		if (protocol == "copy")
		{
			return copyFile(sourcePath, sourceFile, targetPath, callback); // full copying
		}
		else if (protocol == "file")
		{
			// symlinking
			unlink(targetPath.c_str()); // yep, no error handling;
			if (symlink(sourcePath.c_str(), targetPath.c_str()) == -1)
			{
				return format2e("unable to create symbolic link '%s' -> '%s'", targetPath, sourcePath);
			}
			return string();
		}
		else
		{
			fatal2i("a wrong scheme '%s' for the 'file' download method", protocol);
			return string(); // unreachable
		}
	}
void CMasterDAOFactorySQLite::save()
{
    // Closing temp database
    m_PfVersionDAOSQLite->setSQLite(NULL);
    m_PfGamesDAOSQLite->setSQLite(NULL);
    m_PfUsersDAOSQLite->setSQLite(NULL);

    sqlite3_close(m_database);
    m_database = NULL;

    // Copying data to original database
    copyFile(m_filepath_tmp, m_filepath);
    LOG_DEBUG("[CMasterDAOFactorySQLite::save] SQLite Database saved: '%s'", m_filepath.c_str());

    // Reopening temp database
    if( sqlite3_open(m_filepath_tmp.c_str(), &m_database )!=SQLITE_OK ){
        sqlite3_close(m_database);
        m_database = NULL;
        throw PFEXCEPTION("Can't open database file: '%s' --> '%s'", m_filepath_tmp.c_str(), sqlite3_errmsg(m_database));
    }

    m_PfVersionDAOSQLite->setSQLite(m_database);
    m_PfGamesDAOSQLite->setSQLite(m_database);
    m_PfUsersDAOSQLite->setSQLite(m_database);
}
bool QGenieExport2DiskFileThread::copyMacOSAppBundle(const QString &destDir)
{
    const char* file2copy_array[] =
    {
        ":/GenieWirelessConfig.app/Contents/MacOS/GenieWirelessConfig",
        ":/GenieWirelessConfig.app/Contents/Resources/English.lproj/InfoPlist.strings",
        ":/GenieWirelessConfig.app/Contents/Resources/English.lproj/MainMenu.nib",
        ":/GenieWirelessConfig.app/Contents/Resources/GenieWirelessConfig.icns",
        ":/GenieWirelessConfig.app/Contents/Info.plist",
        ":/GenieWirelessConfig.app/Contents/PkgInfo",
        NULL
    };

    int index = 0;
    while(file2copy_array[index] != NULL)
    {
        if(!copyFile(QString(file2copy_array[index]),destDir))
        {
            return false;
        }

        ++index;
    }

    return true;
}
Esempio n. 16
0
void ZipTest::test_openAppendToZipWithFileAlreadyExisting() {
    bool expected = false;
    std::string zipFileName = tempFolder + "/" + zipFile;

    createFolder(zipFileName);
    copyFile(zipFile, zipFileName);

    //first open
    zip->open(zipFileName, OpenFlags::OpenExisting);
    std::string theString("Lorem Ipsum...");
    std::vector<unsigned char> content;
    content.insert(content.end(), theString.begin(), theString.end());
    zip->addFile("file1.txt", content);
    zip->close();

    //second open
    zip->open(zipFileName, OpenFlags::OpenExisting);
    theString = "Lorem Ipsum Number 2...";
    content.insert(content.end(), theString.begin(), theString.end());
    bool actual = zip->addFile("file1.txt", content);
    zip->close();

    CPPUNIT_ASSERT_EQUAL_MESSAGE("add", expected, actual);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("contains", true, containsFile(zipFileName, "file1.txt"));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("count", 7, numFilesInZip(zipFileName));
}
Esempio n. 17
0
File: Copy.c Progetto: Bipsy/Linux
int main(int argc, char** argv) {

    checkArgs(argc, argv);
    copyFile(argv[1], argv[2]);

    return 0;
}
Esempio n. 18
0
void removeSegmentInfoInformation(RVMINFO* currNode, const char* segment) {
    char* segInfoFileName = combinePaths(currNode->directory, SEGINFO_FILE);
    FILE* fd = fopen(segInfoFileName, "r");
    if (fd) {
        char line[1024];
        char *tempFileName = combinePaths(currNode->directory, "lrvmSEGINFO""tmp");
        FILE* tempFIleFd = fopen(tempFileName, "w");
        while (readLineFromFile(fd,line,sizeof(line))) {
            if (startsWith(SEGNAMESTR, line) && !strcmp(line + strlen(SEGNAMESTR), segment)) {
                readLineFromFile(fd,line,sizeof(line));
            } else {
                fprintf(tempFIleFd, "%s\n", line);
            }
        }
        fclose(tempFIleFd);
        fclose(fd);
        copyFile(tempFileName, segInfoFileName);
        deleteFile(tempFileName);
        free(tempFileName);
        char* targetSegmentFile = combinePaths(currNode->directory, segment);

        //Delete the backing store
        deleteFile(targetSegmentFile);
        free(targetSegmentFile);
    }
    free(segInfoFileName);
}
int main(int argc, char *argv[])
{
    int i, src, dest;
    char buffer[BUF_SIZE];

    if(argc != 3)  /*	We need exactly 2 arguments.	*/
	return (1);

    if((src = open(argv[1], O_RDONLY)) == -1) {
	close(src);/*	Opening the source file.	*/
	return (1);
    }

    if((dest = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1) {
	close(dest); /* Opening the destination file.	*/
	return (1);
    }

    if((i = copyFile(src, dest, buffer)) == 1)
	return i;	/*	Making the copy.	*/
	
    if(close(src) == -1 || close(dest) == -1)
	return (1);	/*	Closing the files.	*/
    
    return (0);
}
Esempio n. 20
0
/**
 * Moves file from source <code>srcPath</code> to destination <code>destPath</code>.
 *
 * @param srcPath source full file path.
 * @param destPath destination full file path.
 * @param overwrite whether to overwrite existing file.
 * @throws IOException exception is thrown if overwrite flag is set to false and destination file already exists.
 *         Or the file move operation failed.
 */
void digidoc::util::File::moveFile(const std::string& srcPath, const std::string& destPath, bool overwrite) throw(IOException)
{
    if(!fileExists(srcPath))
    {
        THROW_IOEXCEPTION("Source file '%s' does not exist.", srcPath.c_str());
    }

    if(!overwrite && fileExists(destPath))
    {
        THROW_IOEXCEPTION("Destination file exists '%s' can not move to there. Overwrite flag is set to false.", destPath.c_str());
    }

    f_string _srcPath = encodeName(srcPath);
    f_string _destPath = encodeName(destPath);
    int result = f_rename(_srcPath.c_str(), _destPath.c_str());
    if ( result != 0 )
    {
		// -=K=-: copy and remove source should work as move between different partitions
		copyFile( srcPath, destPath, overwrite );
        result = f_remove( _srcPath.c_str() );
    }
	if ( result != 0 )
	{
		// -=K=-: suceeded to copy, failed to remove. Should we throw or warn?
		WARN( "Failed to remove source file '%s' when moving it to '%s'.", _srcPath.c_str(), _destPath.c_str() );
	}

}
Esempio n. 21
0
/*------------------------------------------------------------------
 * process the imbed file option
 *------------------------------------------------------------------*/
void processImbedFile(
   char *imbedFileName
   )
   {
   FILE *file;

   /*---------------------------------------------------------------
    * while we have imbedFileNames
    *---------------------------------------------------------------*/
   imbedFileName = strtok(imbedFileName,";,");
   while (imbedFileName)
      {
      /*------------------------------------------------------------
       * open the imbed file
       *------------------------------------------------------------*/
      file = fopen(imbedFileName,"r");

      /*------------------------------------------------------------
       * print error if not found, or copy it in if found
       *------------------------------------------------------------*/
      if (!file)
         cPostError(0,"unable to open file '%s' for reading",imbedFileName);
      else
         {
         copyFile(file,info.oFile);
         fclose(file);
         }

      /*------------------------------------------------------------
       * get next imbed file name
       *------------------------------------------------------------*/
      imbedFileName = strtok(NULL,";,");
      }
   }
Esempio n. 22
0
void FileManager::run()
{
    qDebug() << "run the thread to copy file...";

    if( isPath( srcfileName) )
    {
        //qDebug() << srcfileName << destinationPath;
        copyFolder(srcfileName, destinationPath);
    }
    else
    {
        copyFile(srcfileName, destinationPath);
    }

    qDebug() << "copy done!";

//    fileSize = src.size();
//    int oldPercent = 0;
//    for(qint64 index = 0; index < fileSize; ++index)
//    {
//        dst.write(src.read(index));
//        src.seek(index);
//        dst.seek(index);

//        int percent = ((index + 1) * 100) / fileSize;
//        if (oldPercent != percent)
//        {
//            emit verificationProgressSignal(percent);
//            oldPercent = percent;
//        }
//    }
    //emit verificationDone();
}
Esempio n. 23
0
void Thread::run()
{
    stopped = false;
    inputFlag = 1;
    stop = true;
    totalSize = 0;
    QStringList text = content.split("\n");
     for(int i = 0;i < text.length(); i++)
     {
         QFile cFile(text[i]);
         QString toPath;
         if(toDirecory[0] != "/")
             toPath = toDirecory[0] + "/" +  text[i].split("/")[text[i].split("/").length() - 1] ;
         else
             toPath = toDirecory[0] +  text[i].split("/")[text[i].split("/").length() - 1] ;

         if(!cFile.exists())
         {
             inputFlag = -2;
             stopped = true;
             return;
         }
        if(!copyFile(text[i],toPath))
        {
            inputFlag = -1;
            stopped = true;
            return;
        }
     }
    stopped = true;
}
Esempio n. 24
0
bool copyDynlibs( Options& options, const String& mp, const std::vector<String>& dynlibs )
{
   // On windows, the thing is simple. 
   // We must add the module named as <module>.dll besides the host module if it's binary, 
   // or in the Falcon system dir if it's a source module.

   Path modpath( mp );
   Path targetPath;
   String ext = modpath.getExtension();
   ext.lower();

   // binary module ?
   if( ext == DllLoader::dllExt() )
      targetPath.setFullLocation( options.m_sTargetDir + "/" + options.m_sSystemRoot );
   else
      targetPath = modpath;

   bool retval = true;
   for ( uint32 i = 0; i < dynlibs.size(); ++i )
   {
      modpath.setFilename( dynlibs[i] + "." + DllLoader::dllExt() );
      targetPath.setFilename( dynlibs[i] + "." +  DllLoader::dllExt() );

      if( ! copyFile( modpath.get(), targetPath.get() ) )
      {
         warning( "Cannot copy dynlib resource " + modpath.get() );
         retval = false;
      }
   }
   
   return retval;
}
Esempio n. 25
0
void operationThread::dirRound(QString down){

    QDirIterator it(down,QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden,QDirIterator::Subdirectories);

    while (it.hasNext()) {
        if (canceled)
            return;

        while (stopped) msleep(DELAY);
        if (canceled)
            return;


        QFileInfo tmp(it.next());

        if (tmp.isDir()&&!tmp.isSymLink()){
            if (param->type!=1) mkDir(tmp);

        }
        else
            if(param->type!=1) copyFile(tmp);
            else delFile(tmp);
        if (canceled) return;
    }

}
Esempio n. 26
0
bool CGameString::LoadConfig()
{
  char* fileName = "GameString.txt";
  if (!IsFileExist(fileName, TXT_PATH))
    copyFile(fileName, TXT_PATH);
  string fullFilePath = getFilePath(fileName, TXT_PATH);
  int fileLen = strlen(fullFilePath.c_str());
  if (!fileLen)
    return false;
  char buffer[256];  
  ifstream in(fullFilePath);  
  if (! in.is_open())  
  { 
    cout << "Error opening file ItemProperty"; 
    return false; 
  }
  int Line = 0;
  while (EOF != in.peek() )  
  { 
    in.getline (buffer,256);
    GParse GP(buffer);
    GP.getInt();
    string Descibe = GP.getString();
    GameStrings.push_back(/*FontToUTF8*/(Descibe.c_str()));
  }  
  return true;
}
Esempio n. 27
0
void CConfigManager::makedefault(void)
{
	CConfigReader reader;
	if(!copyFile(m_defaultFilePath.c_str(), m_mainFilePath.c_str()))
	{
		errorf("CConfigManager::CConfigManager() copy config file failed\n");
		assert(0);
	}
	else
	{
		if (!readConfig(m_defaultFilePath.c_str(), m_stream))
		{
			errorf("default config error!\n");
			assert(0);
		}
		else
		{
			if(reader.parse(m_stream, m_configDefault))
			{
				tracepoint();
				m_configAll = m_configDefault;
				std::cout << m_configAll << std::endl;
			}
			else
			{
				errorf("read default error!\n");
				assert(0);
			}
		}
	}
}
Esempio n. 28
0
main(int argc, char *argv[])
{
	int entryType;
	char *srcPath, *destPath;
	STAT srcStatBuf, destStatBuf;


	if(argc < 3)
	{
		printf("Hey! Use copy command like: cp [src] [dest]\n");
		return;
	}

	srcPath = argv[1];
	destPath = argv[2];

	stat(srcPath, &srcStatBuf);
	stat(destPath, &destStatBuf);

	// Check for copying a directory or not
	// 0x41ED
	if(srcStatBuf.st_mode == 0x41ED)
	{
		copyDir(srcPath, destPath);
	}
	else
	{
		copyFile(srcPath, destPath);
	}
	
}
void MeshSerializerTests::testMesh_Version_1_2()
{
	// Exporting legacy Mesh not supported!
	// testMesh(MESH_VERSION_LEGACY);

#ifdef I_HAVE_LOT_OF_FREE_TIME
	// My sandboxing test. Takes a long time to complete!
	// Runs on all meshes and exports all to every Lod version.
	char* groups [] = { "Popular", "General", "Tests" };
	for (int i = 0; i < 3; i++) {
		StringVectorPtr meshes = ResourceGroupManager::getSingleton().findResourceNames(groups[i], "*.mesh");
		StringVector::iterator it, itEnd;
		it = meshes->begin();
		itEnd = meshes->end();
		for (; it != itEnd; it++) {
			try {
				mMesh = MeshManager::getSingleton().load(*it, groups[i]);
			}
			catch(std::exception e)
			{
				// OutputDebugStringA(e.what());
			}
			getResourceFullPath(mMesh, mMeshFullPath);
			if (!copyFile(mMeshFullPath + ".bak", mMeshFullPath)) {
				// If there is no backup, create one.
				copyFile(mMeshFullPath, mMeshFullPath + ".bak");
			}
			mOrigMesh = mMesh->clone(mMesh->getName() + ".orig.mesh", mMesh->getGroup());
			testMesh_XML();
			testMesh(MESH_VERSION_1_10);
			testMesh(MESH_VERSION_1_8);
			testMesh(MESH_VERSION_1_7);
			testMesh(MESH_VERSION_1_4);
			testMesh(MESH_VERSION_1_0);
		}
		meshes = ResourceGroupManager::getSingleton().findResourceNames(groups[i], "*.skeleton");
		it = meshes->begin();
		itEnd = meshes->end();
		for (; it != itEnd; it++) {
			mSkeleton = SkeletonManager::getSingleton().load(*it, groups[i]);
			getResourceFullPath(mSkeleton, mSkeletonFullPath);
			if (!copyFile(mSkeletonFullPath + ".bak", mSkeletonFullPath)) {
				// If there is no backup, create one.
				copyFile(mSkeletonFullPath, mSkeletonFullPath + ".bak");
			}
			SkeletonSerializer skeletonSerializer;
			skeletonSerializer.exportSkeleton(mSkeleton.get(), mSkeletonFullPath, SKELETON_VERSION_1_8);
			mSkeleton->reload();
			skeletonSerializer.exportSkeleton(mSkeleton.get(), mSkeletonFullPath, SKELETON_VERSION_1_0);
			mSkeleton->reload();
		}
	}
#endif /* ifdef I_HAVE_LOT_OF_FREE_TIME */
}
Esempio n. 30
-1
File: entry.c Progetto: mapad/ctags
/*  Replacement for missing library function.
 */
static int replacementTruncate (const char *const name, const long size)
{
	char *tempName = NULL;
	FILE *fp = tempFile ("w", &tempName);
	fclose (fp);
	copyFile (name, tempName, size);
	copyFile (tempName, name, WHOLE_FILE);
	remove (tempName);
	eFree (tempName);

	return 0;
}