当前位置: 首页>>代码示例>>C++>>正文


C++ deleteFile函数代码示例

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


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


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