• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ deleteFile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中deleteFile函数的典型用法代码示例。如果您正苦于以下问题:C++ deleteFile函数的具体用法?C++ deleteFile怎么用?C++ deleteFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了deleteFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: switch

bool GameInfo::DeleteGame() {
	switch (fileType) {
	case FILETYPE_PSP_ISO:
	case FILETYPE_PSP_ISO_NP:
		{
			// Just delete the one file (TODO: handle two-disk games as well somehow).
			const char *fileToRemove = fileInfo.fullName.c_str();
			deleteFile(fileToRemove);
			auto i = std::find(g_Config.recentIsos.begin(), g_Config.recentIsos.end(), fileToRemove);
			if (i != g_Config.recentIsos.end()) {
				g_Config.recentIsos.erase(i);
			}
			return true;
		}
	case FILETYPE_PSP_PBP_DIRECTORY:
		{
			// TODO: This could be handled by Core/Util/GameManager too somehow.

			const char *directoryToRemove = fileInfo.fullName.c_str();
			INFO_LOG(HLE, "Deleting %s", directoryToRemove);
			if (!File::DeleteDirRecursively(directoryToRemove)) {
				ERROR_LOG(HLE, "Failed to delete file");
				return false;
			}
			g_Config.CleanRecent();
			return true;
		}

	default:
		return false;
	}
}
开发者ID:metalex10,项目名称:PPSSPP-X360,代码行数:32,代码来源:GameInfoCache.cpp


示例2: deleteDir

int deleteDir(char *dirname) {
  char __aligned buffer[2048];
  struct ExAllControl *ec;
  int moreFromExAll, success = TRUE;
  BPTR lock;

  if(!(lock = Lock(dirname, ACCESS_READ))) {
    return 1;
  }
  printf("Deleting all files in directory %s\n", dirname);

  ec = (struct ExAllControl *) AllocDosObject(DOS_EXALLCONTROL, NULL);
  ec->eac_LastKey=0L;
  ec->eac_MatchString=NULL;
  ec->eac_MatchFunc=NULL;
  do {
    moreFromExAll = ExAll(lock, (struct ExAllData *)buffer, 2048, ED_TYPE, ec);
    if(!handleExAllResult(ec, (struct ExAllData *) buffer, dirname)) {
      success = FALSE;
      break;
    }
  } while(moreFromExAll);
  
  UnLock(lock);
  FreeDosObject(DOS_EXALLCONTROL,ec);
  if(success) {
    success = deleteFile(dirname);
  }
  return success;
}
开发者ID:punktniklas,项目名称:NiKom,代码行数:30,代码来源:InitNiKom.c


示例3: GETCLOCKS

bool FileLogLocation::OpenFile() {
	_canLog = false;
	_fileStream.close();
	_fileIsClosed = true;
	double ts;
	GETCLOCKS(ts);
	ts = (ts / CLOCKS_PER_SECOND)*1000;
	string temp = format("%s.%"PRIu64".%"PRIu64, STR(_fileName), (uint64_t) getpid(), (uint64_t) ts);
	ios_base::openmode openMode = ios_base::out | ios_base::binary | ios_base::trunc;
	_fileStream.open(STR(temp), openMode);
	if (_fileStream.fail()) {
		return false;
	}
	_fileStream << "PID: " << getpid() << "; TIMESTAMP: " << time(NULL) << endl;
	if (_fileHistorySize > 0) {
		ADD_VECTOR_END(_history, temp);
		while (_history.size() > _fileHistorySize) {
			deleteFile(_history[0]);
			_history.erase(_history.begin());
		}
	}
	_currentLength = 0;
	_canLog = true;
	_fileIsClosed = false;
	return true;
}
开发者ID:jacklgp,项目名称:xhome,代码行数:26,代码来源:fileloglocation.cpp


示例4: FATAL

InboundNamedPipeCarrier *InboundNamedPipeCarrier::Create(string path,
		uint16_t mode) {
	if (mkfifo(STR(path), mode) != 0) {
		int err = errno;
		FATAL("Unable to create named pipe %s with mode %u: %s (%d)",
				STR(path), (uint32_t) mode, strerror(err), err);
		return NULL;
	}

	int32_t fd = open(STR(path), O_RDONLY | O_NONBLOCK);
	if (fd < 0) {
		int err = errno;
		FATAL("Unable to open named pipe %s:%s (%d)",
				STR(path), strerror(err), err);
		deleteFile(path);
		return NULL;
	}

	InboundNamedPipeCarrier *pResult = new InboundNamedPipeCarrier(fd, path);

	if (!IOHandlerManager::EnableReadData(pResult)) {
		FATAL("Unable to enable read event on the named pipe");
		delete pResult;
		return NULL;
	}

	return pResult;
}
开发者ID:Undev,项目名称:crtmpserver,代码行数:28,代码来源:inboundnamedpipecarrier.cpp


示例5: createNewSegment

void createNewSegment(const char *directory, const char *segment, unsigned long size, int extendSegment) {
    char* segInfoFileName = combinePaths(directory, SEGINFO_FILE);
    FILE* fd = fopen(segInfoFileName, "r");
    if (fd) {
        char line[1024];
        char *tempFileName = combinePaths(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));
                fprintf(tempFIleFd, "%s%s\n", SEGNAMESTR, segment);
                sprintf(line, "%s%lu", SEGSIZESTR, size);
                fprintf(tempFIleFd, "%s\n", line);
            } else {
                fprintf(tempFIleFd, "%s\n", line);
            }
        }
        if (!extendSegment) {
            fprintf(tempFIleFd, "%s%s\n", SEGNAMESTR, segment);
            sprintf(line, "%s%lu", SEGSIZESTR, size);
            fprintf(tempFIleFd, "%s\n", line);
        }
        fclose(tempFIleFd);
        fclose(fd);
        copyFile(tempFileName, segInfoFileName);
        deleteFile(tempFileName);
        free(tempFileName);

    } else {
        fprintf(stderr, "STDERR:unable to read seg info file\n");
        abort();
    }

    free(segInfoFileName);
    struct stat fileInfo;
    char* targetSegmentFile = combinePaths(directory, segment);
    if (extendSegment && !stat(targetSegmentFile, &fileInfo)) {
        char tempSegFileName[1024];
        sprintf(tempSegFileName, "%s/%s%s%s", directory, SEGINFO_FILE, segment, "tmp");
        copyExtended(targetSegmentFile, tempSegFileName, size);
        copyFile(tempSegFileName, targetSegmentFile);
        deleteFile(tempSegFileName);
    } else {
        createNullFile(targetSegmentFile, size);
    }
    free(targetSegmentFile);
}
开发者ID:Machiry,项目名称:AOS,代码行数:47,代码来源:segutilities.c


示例6: openTrackerDatabase

void LocalStorageDatabaseTracker::deleteAllDatabases()
{
    m_origins.clear();

    openTrackerDatabase(SkipIfNonExistent);
    if (!m_database.isOpen())
        return;

    SQLiteStatement statement(m_database, "SELECT origin, path FROM Origins");
    if (statement.prepare() != SQLITE_OK) {
        LOG_ERROR("Failed to prepare statement.");
        return;
    }

    int result;
    while ((result = statement.step()) == SQLITE_ROW) {
        deleteFile(statement.getColumnText(1));

        // FIXME: Call out to the client.
    }

    if (result != SQLITE_DONE)
        LOG_ERROR("Failed to read in all origins from the database.");

    if (m_database.isOpen())
        m_database.close();

    if (!deleteFile(trackerDatabasePath())) {
        // In the case where it is not possible to delete the database file (e.g some other program
        // like a virus scanner is accessing it), make sure to remove all entries.
        openTrackerDatabase(SkipIfNonExistent);
        if (!m_database.isOpen())
            return;

        SQLiteStatement deleteStatement(m_database, "DELETE FROM Origins");
        if (deleteStatement.prepare() != SQLITE_OK) {
            LOG_ERROR("Unable to prepare deletion of all origins");
            return;
        }
        if (!deleteStatement.executeCommand()) {
            LOG_ERROR("Unable to execute deletion of all origins");
            return;
        }
    }

    deleteEmptyDirectory(m_localStorageDirectory);
}
开发者ID:ollie314,项目名称:webkit,代码行数:47,代码来源:LocalStorageDatabaseTracker.cpp


示例7: create

/* main test functions */
int create(void)
{
   char buf[4096];
   char *s;
   int i;
   int ret = 1;
   char *spec;
   if ( ret && createDir(testDir) )
      ret = 0;

   if ( totalSize < maxSize )
   {
       maxSize = totalSize;
   }
   int nb = maxSize;
   spec = specToName(0, nb, csv);

   STARTTIME();
   for(i=0;i < nb &&createFileBefore;i++)
   {
      snprintf(buf,sizeof(buf), "%s/f_%d",testDir,i);
      int fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
      if ( fd > 0 )
      {
         close(fd);
      }
      else
      {
         ret = 0;
         break;
      }
   }
   ENDTIME();
   SETDT();
   double createPerSecond = nb*1000000.0/dt;

   fprintf(stdout,"Create %-18s time %8.3f sec %8.0f     F/s\n",
           spec,
           (double)dt/1000000,
           createPerSecond
           );
   STARTTIME();
   for(i=0;i < nb; i++)
   {
      snprintf(buf,sizeof(buf),"%s/f_%d",testDir,i);
      deleteFile(buf);
   }
   ENDTIME();
   SETDT();
   createPerSecond = nb*1000000.0/dt;
   fprintf(stdout,"Delete %-18s time %8.3f sec %8.0f     F/s\n",
           spec,
           (double)dt/1000000,
           createPerSecond
           );
   
   deleteTestDir(1);
   return ret;
}
开发者ID:darkphase,项目名称:remotefs,代码行数:60,代码来源:perf.c


示例8: ASSERT

void NetscapePluginStream::stop(NPReason reason)
{
    // The stream was stopped before it got a chance to start. This can happen if a stream is cancelled by
    // WebKit before it received a response.
    if (!m_isStarted) {
        ASSERT(reason != NPRES_DONE);
        notifyAndDestroyStream(reason);
        return;
    }

    if (reason == NPRES_DONE && m_deliveryData && !m_deliveryData->isEmpty()) {
        // There is still data left that the plug-in hasn't been able to consume yet.
        ASSERT(m_deliveryDataTimer.isActive());
        
        // Set m_stopStreamWhenDoneDelivering to true so that the next time the delivery timer fires
        // and calls deliverDataToPlugin the stream will be closed if all the remaining data was
        // successfully delivered.
        m_stopStreamWhenDoneDelivering = true;
        return;
    }

    m_deliveryData = nullptr;
    m_deliveryDataTimer.stop();

    if (m_transferMode == NP_ASFILE || m_transferMode == NP_ASFILEONLY) {
        if (reason == NPRES_DONE) {
            // Ensure that the file is created.
            deliverDataToFile(0, 0);
            if (m_fileHandle != invalidPlatformFileHandle)
                closeFile(m_fileHandle);
            
            ASSERT(!m_filePath.isNull());
            
            m_plugin->NPP_StreamAsFile(&m_npStream, m_filePath.utf8().data());
        } else {
            // Just close the file.
            if (m_fileHandle != invalidPlatformFileHandle)
                closeFile(m_fileHandle);
        }

        // Delete the file after calling NPP_StreamAsFile(), instead of in the destructor.  It should be OK
        // to delete the file here -- NPP_StreamAsFile() is always called immediately before NPP_DestroyStream()
        // (the stream destruction function), so there can be no expectation that a plugin will read the stream
        // file asynchronously after NPP_StreamAsFile() is called.
        deleteFile(m_filePath);
        m_filePath = String();

        // NPP_StreamAsFile could call NPN_DestroyStream and destroy the stream.
        if (!m_isStarted)
            return;
    }

    // Set m_isStarted to false before calling NPP_DestroyStream in case NPP_DestroyStream calls NPN_DestroyStream.
    m_isStarted = false;

    m_plugin->NPP_DestroyStream(&m_npStream, reason);

    notifyAndDestroyStream(reason);
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:59,代码来源:NetscapePluginStream.cpp


示例9: deleteFile

void iurlstream::close() {
    std::ifstream::close();
    if (!m_tempFilePath.empty() && fileExists(m_tempFilePath)) {
        deleteFile(m_tempFilePath);
    }
    m_tempFilePath = "";
    m_lastError = 0;
}
开发者ID:afayek1,项目名称:stanford,代码行数:8,代码来源:urlstream.cpp


示例10: main

int main()
{
    readFile( fileToRead );
    TMyApp myApp;
    myApp.run();
    deleteFile();
    return 0;
}
开发者ID:Mikelle02,项目名称:GameMaker,代码行数:8,代码来源:TVGUID12.CPP


示例11: deleteFile

Field::~Field()
{
	for(int i=0 ; i<files.size() ; ++i) {
		deleteFile((FileType)i);
	}

	deleteCharaFile();
}
开发者ID:JeMaCheHi,项目名称:deling,代码行数:8,代码来源:Field.cpp


示例12: UNUSED_PARAM

void OriginLock::deleteLockFile(String originPath)
{
    UNUSED_PARAM(originPath);
#if USE(FILE_LOCK)
    String lockFileName = OriginLock::lockFileNameForPath(originPath);
    deleteFile(lockFileName);
#endif
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:8,代码来源:OriginLock.cpp


示例13: endError

void endError(){
	
	// clean up
	if(tempClausesFileGlobal != NULL){
		fclose(tempClausesFileGlobal);
		deleteFile(TEMP_CLAUSE_FILE);
	}
	exit(0);
}
开发者ID:dbunker,项目名称:SABR,代码行数:9,代码来源:arch.c


示例14: main

int main()
{
	int choice;
	char ans = 'y';
	char fname[SIZE];
	struct linknode *hashTable[TABLESIZE];
	initializeHashTable(hashTable);
	
	while(ans == 'y')
	{
		printf("\n1. Create file\n");
		printf("2. Delete File\n");
		printf("3. Search File\n");
		printf("4. Display Table\n");
		printf("5. Exit\n");
		printf("6. Write to disk\n");
		printf("7. Read from disk\n");
		printf("\nEnter choice: ");
		scanf("%d", &choice);
		switch(choice)
		{
			case 1:
				printf("Enter file name: ");
				scanf("%s", fname);
				insertFile(fname, hashTable);
				break;

			case 2:
				printf("Enter file name: ");
				scanf("%s", fname);
				deleteFile(fname, hashTable);
				break;

			case 3:
				printf("Enter file name: ");
				scanf("%s", fname);
				searchFile(fname, hashTable);
				break;

			case 4:
				displayTable(hashTable);
				break;

			case 5:
				exit(0);

			case 6:
				writeToDisk(hashTable);
				break;

			case 7:
				readFromDisk(hashTable);
				break;
		}
	}
	return (0);
}
开发者ID:sagar13,项目名称:temp,代码行数:57,代码来源:hash.c


示例15: makeAllDirectories

void PluginDatabase::updatePersistentMetadataCache()
{
    if (!isPersistentMetadataCacheEnabled() || persistentMetadataCachePath().isEmpty())
        return;

    makeAllDirectories(persistentMetadataCachePath());
    String absoluteCachePath = pathByAppendingComponent(persistentMetadataCachePath(), persistentPluginMetadataCacheFilename);
    deleteFile(absoluteCachePath);

    if (m_plugins.isEmpty())
        return;

    PlatformFileHandle file;
    file = openFile(absoluteCachePath, OpenForWrite);

    if (!isHandleValid(file)) {
        LOG_ERROR("Unable to open plugin metadata cache for saving");
        return;
    }

    char localSchemaVersion = schemaVersion;
    if (writeToFile(file, &localSchemaVersion, 1) != 1) {
        LOG_ERROR("Unable to write plugin metadata cache schema");
        closeFile(file);
        deleteFile(absoluteCachePath);
        return;
    }

    PluginSet::const_iterator end = m_plugins.end();
    for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
        if (!(writeUTF8String(file, (*it)->path())
              && writeTime(file, (*it)->lastModified())
              && writeUTF8String(file, (*it)->name())
              && writeUTF8String(file, (*it)->description())
              && writeUTF8String(file, (*it)->fullMIMEDescription()))) {
            LOG_ERROR("Unable to write plugin metadata to cache");
            closeFile(file);
            deleteFile(absoluteCachePath);
            return;
        }
    }

    closeFile(file);
}
开发者ID:Moondee,项目名称:Artemis,代码行数:44,代码来源:PluginDatabase.cpp


示例16: writeFile

void writeFile(char * name, char * buffer, int numberOfSectors){
    char dir[512];
    char map[512];
    char tmpSect[512];
    int dirNum = 0;
    int i = 0;
    int sectNum = 0;
    int k = 0;
    int iBuf = 0;
    readSector(dir, 2);
    readSector(map, 1);

    dirNum = findFreeDir(dir);

    if(dirNum >= 16){
        return;
    }
    // Writing the name in directory
    while(name[i] != 0x0){
        dir[dirNum*32+i] = name[i];
        i++;
    }

    // Writing data and map
    for(i = 0; i <= numberOfSectors; i++){
        // Locating free sector
        while(map[sectNum] != 0x0){
            sectNum++;
        }
        if(i >= 16){
            deleteFile(name);
            return;
        }
        printString(name); 
        // Writing to map and directory
        map[sectNum] = 0xFF;
        writeSector(map, 0);
        dir[dirNum*32+6+i] = sectNum;

        // Writing the sector
        for(k = 0; k < 512; k++){
            tmpSect[k] = buffer[iBuf];
            iBuf++;
        }
        writeSector(tmpSect, sectNum);
    }

    // Filling the rest of the dir entry with 0x00
    while(i<16){
        dir[dirNum*32+6+i] = 0x0;
        i++;
    }

    writeSector(map, 1);
    writeSector(dir, 2);
}
开发者ID:JehoG,项目名称:kernel-learning,代码行数:56,代码来源:kernel.c


示例17: deleteFile

/*!
 * Rename a file from oldName to newName. If the file newName already exists
 * it will be deleted.
 * \param oldName is the old name of the file
 * \param newName is the new name of the file
 */
void ProtocolFile::renameFile(const QString& oldName, const QString& newName)
{
    // Make sure the new file does not exist
    deleteFile(newName);

    // Now make the old name become the new name
    makeFileWritable(oldName);
    QFile::rename(oldName, newName);

}// ProtocolFile::renameFile
开发者ID:SchrodingersGat,项目名称:ProtoGen,代码行数:16,代码来源:protocolfile.cpp


示例18: deleteFile

bool File::deleteRecursively() const
{
    bool worked = true;

    if (isDirectory())
        for (auto& f : findChildFiles (File::findFilesAndDirectories, false))
            worked = f.deleteRecursively() && worked;

    return deleteFile() && worked;
}
开发者ID:Sentinel77,项目名称:dexed,代码行数:10,代码来源:juce_File.cpp


示例19: copyFileToFolder

void FileManager::moveFileToFolder(QString originPath, QString originName,QString newPath,QString newName) {
    if(QString::compare(originPath,newPath)==0 && QString::compare(originName,newName)==0) return;
    copyFileToFolder(originPath,originName, newPath, newName);
    historyFromPath.push(originPath);
    historyFromName.push(originName);
    historyToPath.push(newPath);
    historyToName.push(newName);
    historyType.push_back("folder");
    deleteFile(originPath + "/" + originName);
}
开发者ID:brucehsu,项目名称:classiphy,代码行数:10,代码来源:filemanager.cpp


示例20: write

bool FileSystem::sendFileByRange(int connFd, Message_fs msg )
{
    bool deleteMyCopy = ( (msg.type == MSG_PULL_MV) ? true : false );

    logFile<<"sendFileByRange: "<<msg.minKey<<" to "<<msg.maxKey<<endl;

    std::vector<std::string> toremove;
    filesLock.lock();
    size_t count = 0;
    for( auto &file : files ){
        if( inRange(file.key, msg.minKey, msg.maxKey) )
            count++;
    }
    msg.size = count;
    write(connFd, &msg, sizeof(Message_fs));
    for( auto &file : files )
    {
        if( inRange(file.key, msg.minKey, msg.maxKey) )
        {
            memset(msg.filename, '\0', 200);
            file.filename.copy(msg.filename, file.filename.length() );

            // cout<<"sendFileByRange: "<<file.filename<<" "<<msg.filename<<endl;
            logFile<<"sendFileByRange: "<<file.filename<<" rm:"<<deleteMyCopy<<endl;

            char * buffer; 
            msg.size = readFile(file.filename, &buffer);

            write(connFd, &msg, sizeof(Message_fs));
            splitWrite(connFd, buffer, msg.size);

            delete buffer;

            if(deleteMyCopy)
            {
                //files.remove( file );   //maintain file list
                toremove.push_back(file.filename);
            }
        }
    }

    for (int i = 0; i < toremove.size(); ++i)
    {
        if ( deleteFile( toremove.at(i) ) ) 
        {
            logFile << toremove.at(i) << "deleted" << std::endl;
        }
        files.remove(toremove.at(i));
    }

    filesLock.unlock();

    return true;
}
开发者ID:XueweiKent,项目名称:DistributedFileSystem,代码行数:54,代码来源:FileSystem.cpp



注:本文中的deleteFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ deleteIncludedItems函数代码示例发布时间:2022-05-30
下一篇:
C++ deleteDemandDrivenData函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap