예제 #1
0
파일: CodeVw.cpp 프로젝트: mygaldre/mmsstv
//---------------------------------------------------------------------------
void __fastcall TCodeView::SBEditClick(TObject *Sender)
{
	LPCSTR pName = "EUDCEDIT.EXE";
	if( sys.m_Eudc.IsEmpty() ){
		char dir[MAX_PATH];
		char bf[512];
		if( ::GetSystemDirectory(dir, sizeof(dir)) ){
	        wsprintf(bf, "%s\\%s", dir, pName);
            if( IsFile(bf) ) sys.m_Eudc = bf;
		}
		if( sys.m_Eudc.IsEmpty() && ::GetWindowsDirectory(dir, sizeof(dir)) ){
	        wsprintf(bf, "%s\\%s", dir, pName);
            if( IsFile(bf) ) sys.m_Eudc = bf;
        }
		if( sys.m_Eudc.IsEmpty() ){
	        wsprintf(bf, "%c:\\Program Files\\Accessories\\%s", dir[0], pName);
            if( IsFile(bf) ) sys.m_Eudc = bf;
        }
		if( sys.m_Eudc.IsEmpty() ) sys.m_Eudc = pName;
    }
	if( ::WinExec(sys.m_Eudc.c_str(), SW_SHOWDEFAULT) > 31 ){
	    ReqClose();
    }
    else {
		SBEdit->Enabled = FALSE;
        sys.m_fEudc = FALSE;
    }
}
예제 #2
0
파일: tools.cpp 프로젝트: xinll/virtualhost
void RmDir(const char *path)
{
	if(IsFile(path) || IsLnk(path))
	{
		remove(path);
		return;
	}
	char filePath[PATH_MAX];
	if(IsDir(path))
	{
		DIR *dir;
		struct dirent *ptr;
		dir = opendir(path);
		while(ptr = readdir(dir))
		{
			if(IsSpecial(ptr->d_name))
				continue;
			GetFilePath(path,ptr->d_name,filePath);
			if(IsDir(filePath))
			{
				RmDir(filePath);
				rmdir(filePath);
			}
			else if(IsFile(filePath) || IsLnk(filePath))
			{
				remove(filePath);
			}
		}
		closedir(dir);
	}
}
예제 #3
0
bool CExportImageDialog::Check()
{
    if ( Save2D() && IsFile( mOutputFileName2D ) )
    {
        if ( !SimpleQuestion( "Do you want to overwrite existing file " + mOutputFileName2D + " ?" ) )
            return false;
    }

    if ( Save3D() && IsFile( mOutputFileName3D ) )
    {
        if ( !SimpleQuestion( "Do you want to overwrite existing file " + mOutputFileName3D + " ?" ) )
            return false;
    }

    if ( ( Save2D() && mOutputFileName2D.empty() ) || ( Save3D() && mOutputFileName3D.empty() ) )
	{
		SimpleErrorBox( "The output path of the file(s) to save must be specified." );
		return false;
	}
	if ( mOutputFileName2D == mOutputFileName3D )
	{
		SimpleErrorBox( "Cannot save both images to the same file" );
		return false;
	}
	return true;
}
예제 #4
0
void InstallMain(char *name)
{
	char sysdir[MAX_PATH];
	char windir[MAX_PATH];
	char infdir[MAX_PATH];
	char otherdir[MAX_PATH];
	char infname[MAX_PATH];
	char deviceid[MAX_PATH];
	char sysname[MAX_PATH];
	if (name == NULL)
	{
		return;
	}
	if (strlen(name) == 0 || strlen(name) >= 5)
	{
		return;
	}

	GetSystemDirectory(sysdir, sizeof(sysdir));

	GetDirFromPath(windir, sysdir);

	sprintf(infdir, "%s\\inf", windir);

	sprintf(otherdir, "%s\\other", infdir);

	sprintf(infname, "%s\\Neo_%s.inf", infdir, name);

	sprintf(sysname, "%s\\Neo_%s.sys", sysdir, name);

	sprintf(deviceid, "NeoAdapter_%s", name);

	if (IsFile(infname) == FALSE)
	{
		Print("Failed to open %s.", infname);
		return;
	}
	if (IsFile(sysname) == FALSE)
	{
		Print("Failed to open %s.", sysname);
		return;
	}

	if (DiInstallClass(infname, 0) != OK)
	{
		Print("Failed to register %s.\n", infname);
		return;
	}

	if (InstallNDIDevice("Net", deviceid, NULL, NULL) != OK)
	{
		return;
	}
}
예제 #5
0
/**
 * \brief for function IsFile
 * a file
 */
void testIsFileNormal_SymLink()
{
  system("echo 'hello world' > ./test.file");
  char Fname[] = "./test.file";
  int isFile = IsFile(Fname, 0);
  CU_ASSERT_EQUAL(isFile, 1);
  char NewFname[] = "./link.file";
  symlink(Fname, NewFname);
  isFile = IsFile(NewFname, 1);
  CU_ASSERT_EQUAL(isFile, 1);
#if 0
#endif
  RemoveDir(Fname);
  RemoveDir(NewFname);
}
예제 #6
0
파일: Inode.cpp 프로젝트: BDT-GER/SWIFT-TLC
    bool
    Inode::GetSize(off_t & size)
    {
        size = 0;

        if ( ! IsFile() ) {
            if ( 0 == ::stat( Path().string().c_str(), &stat_ ) ) {
                size = stat_.st_size;
                return true;
            } else {
                size = 0;
                return false;
            }
        }

        int valuesize;
        bool ret = xattr_.GetValue(
                ATTRIBUTE_SIZE, &size, sizeof(size), valuesize );
        if ( ret ) {
            return true;
        }

        if ( 0 == ::stat( Path().string().c_str(), &stat_ ) ) {
            size = stat_.st_size;
        } else {
            size = 0;
        }
        return false;
    }
예제 #7
0
const SoundShaderT* SoundShaderManagerImplT::GetSoundShader(const std::string& Name)
{
    // Ignore empty names and just return NULL.
    if (Name.empty()) return NULL;

    // Note that I'm *not* just writing   return SoundShaders[Name]   here, because that
    // would implicitly create a NULL entry for every Name that does not actually exist.
    std::map<std::string, SoundShaderT*>::const_iterator It=m_SoundShaders.find(Name);

    if (It!=m_SoundShaders.end()) return It->second;

    // Sound shader not found, try to interpret the name as a filename or a "capture n" string.
    if (IsFile(Name) || IsCapture(Name))
    {
        SoundShaderT* AutoShader=new SoundShaderT(Name);
        AutoShader->AudioFile=Name;

        // Add auto created shader to list of shaders.
        m_SoundShaders[Name]=AutoShader;

        return AutoShader;
    }

    std::cout << "Error auto creating sound shader: File '" << Name << "' not doesn't exist.\n";
    return NULL;
}
예제 #8
0
파일: fs_mapr.cpp 프로젝트: Minione/iwct
bool MaprFileSystem::Remove(const std::string& uri){
  if (!Exists(uri)){
    VLOG(2) << "Can't remove file, it doesn't exist: " << uri;
    return false;
  }

  std::string path = GetUriPathOrDie(uri);
  std::string host = "default";
  hdfsFS fs = hdfsConnect(host.c_str(), 0); // use default config file settings
  CHECK(fs);
  if (IsFile(uri)){
    //LOG(INFO) << "removing file: " << uri;
    int retval = hdfsDelete(fs, path.c_str());
    CHECK_EQ(retval, 0);
  }
  else if (IsDirectory(uri)){
    //LOG(INFO) << "removing dir: " << uri;
    std::vector<std::string> dir_file_uris;
    CHECK(ListDirectory(uri, &dir_file_uris));
    BOOST_FOREACH(std::string file_uri, dir_file_uris){
      CHECK(Remove(file_uri));
    }
    int retval = hdfsDelete(fs, path.c_str());
    CHECK_EQ(retval, 0);
  }
예제 #9
0
/*******************************************************************
*
* CSVClose
*
*******************************************************************/
int CSVload::Close()
{
	if( !IsFile() ){return 0;}
	if( fclose(m_filePointer) == -1){return -1;}
	m_filePointer = NULL;
	return 1;
}
예제 #10
0
파일: ftp.cpp 프로젝트: kaifengz/fasmio
bool FtpConnHandler::On_RETR()
{
    if (*last_cmd_arg_ == '\0')
        return SendMessage(550, "No file specified.");

    std::string path;
    if (*last_cmd_arg_ == '/')
        path = last_cmd_arg_;
    else
        path = working_dir_ + "/" + last_cmd_arg_;

    if (!NormalizePath(path))
        return SendMessage(550, "File unavailable.");
    if (!IsFile("." + path))
        return SendMessage(550, "Not a file.");

    if (!OpenDataConnection())
        return SendMessage(425, "Can't open data connection.");
    if (!SendMessage(150, "Here comes the file content."))
        return false;

    bool succeed = SendFile("." + path, bin_mode_, sock_data_);
    CloseDataConnection();

    if (!succeed)
        return SendMessage(451, "Requested action aborted: local error in processing.");

    return SendMessage(226, "File send OK.");
}
예제 #11
0
/*Function to check the validity of the
users arguments */ 
void checkArgs (int argc, char **argv){

	//check the number of arguments. Argc must be 3 in this case
	if (argc != 3){
		printf("Query engine only takes 3 arguments\n");
		exit(1);
	}

	//check if the file given for the data is valid
	char *argv1 = argv[1];
	if (IsFile(argv1)){
		printf("%s is a file which exists\n", argv1);
	}
	else{
		printf("%s does not exist. Please enter a path to a data file which exists\n", argv1);	
		exit(1);
	}

	//Check if the second argument is a valid directory
	char* argv2 = argv[2];
	if(IsDir(argv2)){
		printf("%s is a valid directory\n", argv2);
	}
	else{
		printf("%s is not a valid directory\n", argv2);
		exit(1);
	}

	printf("Valid Arguments. Starting indexer\n");

}
예제 #12
0
//---------------------------------------------------------------------------
void __fastcall TFileViewDlg::KPOLClick(TObject *Sender)
{
	if( (m_CurFile < 0) || (pCurPage->pList == NULL) ) return;

	Mmsstv->AdjustPage(pgTemp);
	AnsiString as;
	GetCurFileName(as);
	if( IsFile(as.c_str()) ){
		CDrawOle *pDraw = (CDrawOle *)Mmsstv->DrawMain.MakeItem(CM_OLE);
		LPCSTR pExt = GetEXT(as.c_str());
		if( !strcmpi(pExt, "BMP")){
			pDraw->LoadFromFile(-1, 0, as.c_str());
		}
		else {
			Graphics::TBitmap *pBmp = MakeCurrentBitmap();
			pDraw->LoadFromBitmap(-1, 0, pBmp);
			if( !strcmpi(pExt, "JPG") ){
				pDraw->m_Trans = 0;
				pDraw->m_Stretch = 1;
			}
			delete pBmp;
		}
		Mmsstv->AddItem(pDraw, 0);
	}
}
예제 #13
0
FileInfo *  VFSHandle_ZIP::Read(void)
{
	if(IsFile(m_file) == true){
		char *buffer = (char *)Read(m_length);

		char	*filename	=	m_lfh[m_fileid]->filename;
		char	*tempdir	=	fusion->vfs->GetTempDirectory();

		if(tempdir == NULL){
			fusion->vfs->SetTempDirectory("vfstemp");
			tempdir = fusion->vfs->GetTempDirectory();
		}

		char fn[256];

		sprintf(fn,"%s/%s",tempdir,filename);

		m_handle = fusion->vfs->Open(fn,"binary",true);

		if(m_handle != NULL){
			m_handle->Write(buffer,m_length);
			fusion->vfs->Close(m_handle);
		}

		m_handle = fusion->vfs->Open(fn);

		m_length = m_handle->Length();

		delete[] buffer;

		return m_handle->Read();
	}

	return NULL;
}
예제 #14
0
//---------------------------------------------------------------------------
int __fastcall CThumb::UpdateBitmap(int n)
{
	if( pBitmap == NULL ) return FALSE;

	CloseBitmap();
	n /= THUMBWIND;
	if( n == m_Top ) return TRUE;
	m_Top = n;
	char name[256];
	sprintf(name, "%sFindex\\B%02u%u.bmp", BgnDir, m_FolderIndex, n);
	MultProc();
	int r = FALSE;
	m_UpdateBmp = 1;
	if( IsFile(name) ){
		::LoadBitmap(pBitmap, name);
		MultProc();
		if( (pBitmap->Width != m_XW) || (pBitmap->Height != m_SizeY) ){
			pBitmap->Width = m_XW;
			pBitmap->Height = m_SizeY;
		}
		else {
			m_UpdateBmp = 0;
			r = TRUE;
		}
	}
	if( r == FALSE ){
		n *= THUMBWIND;
		for( int i = n; i < (n + THUMBWIND); i++ ){
			if( i < m_FileCount ) pITBL[i+1].crc = 0;
		}
	}
	MultProc();
	return r;
}
예제 #15
0
/*******************************************************************
*
* IsDemiliter
*
*******************************************************************/
bool CSVload::IsDemiliter()
{
	if( !IsFile() ){return false;}
	if(m_lastChar == ','){ return true; }
	if(m_lastChar == '\n'){ return true; }
	return false;
}
예제 #16
0
bool CopyFileTo(const tstring& sFrom, const tstring& sTo, bool bOverride)
{
	if (IsFile(sTo) && bOverride)
		::DeleteFile(convert_to_wstring(sTo).c_str());

	return !!CopyFile(convert_to_wstring(sFrom).c_str(), convert_to_wstring(sTo).c_str(), true);
}
예제 #17
0
void ListFilesInDirRecursive(const std::string &Dir, long *Epoch,
                             Vector<std::string> *V, bool TopDir) {
  auto E = GetEpoch(Dir);
  if (Epoch)
    if (E && *Epoch >= E) return;

  DIR *D = opendir(Dir.c_str());
  if (!D) {
    Printf("No such directory: %s; exiting\n", Dir.c_str());
    exit(1);
  }
  while (auto E = readdir(D)) {
    std::string Path = DirPlusFile(Dir, E->d_name);
    if (E->d_type == DT_REG || E->d_type == DT_LNK ||
        (E->d_type == DT_UNKNOWN && IsFile(Path)))
      V->push_back(Path);
    else if ((E->d_type == DT_DIR ||
             (E->d_type == DT_UNKNOWN && IsDirectory(Path))) &&
             *E->d_name != '.')
      ListFilesInDirRecursive(Path, Epoch, V, false);
  }
  closedir(D);
  if (Epoch && TopDir)
    *Epoch = E;
}
예제 #18
0
void SetTimidityEnvPath(const Settings & conf)
{
    const std::string prefix_timidity = std::string("files") + SEPARATOR + std::string("timidity");
    const std::string result = Settings::GetLastFile(prefix_timidity, "timidity.cfg");

    if(IsFile(result))
	setenv("TIMIDITY_PATH", GetDirname(result).c_str(), 1);
}
예제 #19
0
bool VFSHandle_file::OpenLocation(std::string loc, bool create )
{
	SetFilename( loc );

	if ( IsDirectory( m_filename ) == false && IsFile( m_filename ) == false && create == true ) CreateDir( m_filename );

	return IsDirectory( m_filename );
}
예제 #20
0
/**
 * \brief for function IsFile 
 * a file
 */
void testIsFileNormal_RegulerFile()
{
  system("echo 'hello world' > ./test.file");
  char Fname[] = "./test.file";
  int isFile = IsFile(Fname, 1);
  CU_ASSERT_EQUAL(isFile, 1);
  RemoveDir(Fname);
}
예제 #21
0
파일: menu.c 프로젝트: k-takata/TClockLight
/*------------------------------------------------
  when the clock is right-clicked
  show pop-up menu
--------------------------------------------------*/
void OnContextMenu(HWND hwnd, HWND hwndClicked, int xPos, int yPos)
{
	WIN32_FIND_DATA fd;
	HANDLE hfind;
	TPMPARAMS tpmp;
	LPTPMPARAMS lptpmp = NULL;
	
	SendOnContextMenu();
	
	if(m_tcmenutxt[0] == 0 || !IsFile(m_tcmenutxt))
	{
		// common/tclang.c
		FindFileWithLangCode(m_tcmenutxt, GetUserDefaultLangID(), TCMENUTXT);
	}
	
	hfind = FindFirstFile(m_tcmenutxt, &fd);
	if(hfind != INVALID_HANDLE_VALUE)
	{
		FindClose(hfind);
		if(m_lasttime != fd.ftLastWriteTime.dwLowDateTime)
		{
			EndContextMenu();
			m_lasttime = fd.ftLastWriteTime.dwLowDateTime;
		}
	}
	else m_lasttime = 0;
	
	// create popup menu and append items from tcmenu.txt
	if(!m_hMenu)
	{
		m_hMenu = CreatePopupMenu();
		if(hfind != INVALID_HANDLE_VALUE)
			LoadMenuFromText(m_hMenu, m_tcmenutxt, &fd);
		else
			LoadMenuFromText(m_hMenu, NULL, NULL);
	}
	
	CheckMenu(m_hMenu);
	
	// get keyboard input
	SetFocusTClockMain(hwnd);
	
	// APP key
	if((xPos == -1) && (yPos == -1))
	{
		tpmp.cbSize = sizeof(tpmp);
		lptpmp = &tpmp;
		GetWindowRect(g_hwndClock, &tpmp.rcExclude);
		xPos = tpmp.rcExclude.right;
		yPos = tpmp.rcExclude.top;
	}
	
	// open popup menu
	TrackPopupMenuEx(m_hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON,
		xPos, yPos, hwnd, lptpmp);
	
	PostMessage(hwnd, WM_NULL, 0, 0);
}
예제 #22
0
void ReadConfigs(void)
{
    Settings & conf = Settings::Get();
    ListFiles files = conf.GetListFiles("", "fheroes2.cfg");

    for(ListFiles::const_iterator
	it = files.begin(); it != files.end(); ++it)
    	if(IsFile(*it)) conf.Read(*it);
}
예제 #23
0
/*******************************************************************
*
* CharGet
*
*******************************************************************/
char CSVload::CharGet()
{
	if( !IsFile() ){ return EOF; }
	char result = m_lastChar;
	if(!IsEof()){
		m_lastChar = fgetc(m_filePointer);
	}
	return result;
}
예제 #24
0
파일: Dataset.cpp 프로젝트: BRAT-DEV/main
//v4 Returns list of files in error (not found) for client code to display
//
bool CDataset::CtrlFiles( std::vector< std::string > &v )
{
	for ( CProductList::iterator it = m_files.begin(); it != m_files.end(); it++ )
	{
		if ( !IsFile( it->c_str() ) )
			v.push_back(*it);
	}
	return v.empty();
}
예제 #25
0
/**	Opens a file
 *
 *	@param filename	The name of the file to open
 *	@param create		Whether to create a non-existant file or return false
 *
 *	@returns boolean true or false, depending on whether was able to open
 *
 *	Operation:
 *		-#	The filename will be preceeded by "file://" so move the filename 
 *				pointer forward, past the vfs specific section of the file, and 
 *				to the actual filename itself e.g. file://image.jpg => image.jpg
 *		-#	Opens a filestream with read/write capabilities in binary mode
 *		-#	Sets the handles filename
 *		-#	Attempts to open the file
 *		-#	If successful, calculates the length of the file
 *		-#	returns whether the file was opened successfully
 *
 *	@todo	Add functionality to decide whether to create a new file, if the file requested does not exist
 */
bool VFSHandle_file::Open(std::string filename, bool create )
{
	SetFilename( filename );

	if ( IsFile( m_filename ) == false && create == true ) Createfile( m_filename );

	if ( IsFile( m_filename ) == true )
	{
		m_stream.clear();
		m_stream.open( m_filename.c_str(), std::ios::in | std::ios::out | std::ios::binary );

		Length();

		return ( bool ) m_stream.is_open();
	}

	return false;
}
예제 #26
0
파일: Inode.cpp 프로젝트: BDT-GER/SWIFT-TLC
    bool
    Inode::GetTape(string & tape)
    {
        if ( ! IsFile() ) {
            return false;
        }

        return xattr_.GetStringValue(ATTRIBUTE_TAPE, tape);
    }
예제 #27
0
파일: Inode.cpp 프로젝트: BDT-GER/SWIFT-TLC
    bool
    Inode::SetSize(off_t size)
    {
        if ( ! IsFile() ) {
            return false;
        }

        return xattr_.SetValue(ATTRIBUTE_SIZE,&size,sizeof(size));
    }
예제 #28
0
/*******************************************************************
*
* IsEscapeSequence
*
*******************************************************************/
bool CSVload::IsEscapeSequence()
{
	if( !IsFile() ){return false;}
	if( m_lastChar == '\r' ){ return true; }
	if( m_lastChar == '\t' ){ return true; }
	if( m_lastChar == ' ' ){ return true; }

	return false;
}
예제 #29
0
파일: MEmbedFile.cpp 프로젝트: galek/MIngEd
void MEmbedFile::open(const char* path, const char* mode)
{
    M_PROFILE_SCOPE(MEmbedFile::open);
    if(IsFile(path))
    {
	m_Open = true;
	m_Ptr = m_File;
    }
}
예제 #30
0
void PhSrvDebugInfo::CPhSrvDebugData::WriteFile(const TDesC8& aDes)
    {
    if ( IsFile() )
        {
        TInt place =0 ;
        iFile->Seek( ESeekEnd,place );
        iFile->Write( place, aDes );
        iFile->Flush();
        }
    }