本文整理汇总了C++中FileExists函数的典型用法代码示例。如果您正苦于以下问题:C++ FileExists函数的具体用法?C++ FileExists怎么用?C++ FileExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FileExists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ResolveSupersede
BOOL ResolveSupersede(siC *siCObject, greInfo *aGre)
{
DWORD dwIndex;
char szFilePath[MAX_BUF];
char szSupersedeFile[MAX_BUF];
char szSupersedeVersion[MAX_BUF];
char szType[MAX_BUF_TINY];
char szKey[MAX_BUF_TINY];
verBlock vbVersionNew;
verBlock vbFileVersion;
siCObject->bSupersede = FALSE;
if(siCObject->dwAttributes & SIC_SUPERSEDE)
{
dwIndex = 0;
GetConfigIniProfileString(siCObject->szReferenceName, "SupersedeType", "", szType, sizeof(szType));
if(*szType !='\0')
{
if(lstrcmpi(szType, "File Exists") == 0)
{
wsprintf(szKey, "SupersedeFile%d", dwIndex);
GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeFile, sizeof(szSupersedeFile));
while(*szSupersedeFile != '\0')
{
DecryptString(szFilePath, szSupersedeFile);
if(FileExists(szFilePath))
{
wsprintf(szKey, "SupersedeMinVersion%d",dwIndex);
GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeVersion, sizeof(szSupersedeVersion));
if(*szSupersedeVersion != '\0')
{
if(GetFileVersion(szFilePath,&vbFileVersion))
{
/* If we can get the version, and it is greater than or equal to the SupersedeVersion
* set supersede. If we cannot get the version, do not supersede the file. */
TranslateVersionStr(szSupersedeVersion, &vbVersionNew);
if(CompareVersion(vbFileVersion,vbVersionNew) >= 0)
{
siCObject->bSupersede = TRUE;
break; /* Found at least one file, so break out of while loop */
}
}
}
else
{ /* The file exists, and there's no version to check. set Supersede */
siCObject->bSupersede = TRUE;
break; /* Found at least one file, so break out of while loop */
}
}
wsprintf(szKey, "SupersedeFile%d", ++dwIndex);
GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeFile, sizeof(szSupersedeFile));
}
}
else if(lstrcmpi(szType, "GRE") == 0)
{
/* save the GRE component */
aGre->siCGreComponent = siCObject;
/* If -fgre is passed in, and the current product to install is !GRE,
* and the current component is 'Component GRE' then select and
* disable it to force it to be installed regardless of supersede
* rules.
*
* If the product is GRE, then it won't have a 'Component GRE', but
* rather a 'Component XPCOM', in which case it will always get
* installed */
if((gbForceInstallGre) && (lstrcmpi(sgProduct.szProductNameInternal, "GRE") != 0))
{
siCObject->dwAttributes |= SIC_SELECTED;
siCObject->dwAttributes |= SIC_DISABLED;
}
else
ResolveSupersedeGre(siCObject, aGre);
}
}
if(siCObject->bSupersede)
{
siCObject->dwAttributes &= ~SIC_SELECTED;
siCObject->dwAttributes |= SIC_DISABLED;
siCObject->dwAttributes |= SIC_INVISIBLE;
}
else
/* Make sure to unset the DISABLED bit. If the Setup Type is other than
* Custom, then we don't care if it's DISABLED or not because this flag
* is only used in the Custom dialogs.
*
* If the Setup Type is Custom and this component is DISABLED by default
* via the config.ini, it's default value will be restored in the
* SiCNodeSetItemsSelected() function that called ResolveSupersede(). */
siCObject->dwAttributes &= ~SIC_DISABLED;
}
return(siCObject->bSupersede);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:94,代码来源:supersede.c
示例2: UpdateData
void CDlgSelCritDB::OnOK()
{
CString strCurCodeName;
CString strCurDBName;
CString strTmp;
UpdateData();
m_ctlMaterCodeName.GetWindowText( EDIBgbl::sCur_MaterialCodeName );
int row = m_ctrlShowCODE.GetSelectionMark();
if( row == -1 )
{
AfxMessageBox("请选择一个行业的规范数据库!");
return;
}
char c[256];
//规范数据库
m_ctrlShowCODE.GetItemText(row, 1, c, 256);
strCurDBName = c;
//当前规范
memset(c,'\0',256);
m_ctrlShowCODE.GetItemText(row, 0, c, 256);
strCurCodeName = c;
//当前规范代号
memset(c,'\0',256);
m_ctrlShowCODE.GetItemText(row, 2, c, 256);
EDIBgbl::sCur_CodeNO = c;
try
{
if ( !FileExists( EDIBgbl::sCritPath + strCurDBName ) )
{
strTmp.Format(IDS_NOT_EXISTS_FILE, EDIBgbl::sCritPath + strCurDBName);
AfxMessageBox( strTmp );
return;
}
CString strCon;
//重新连接标准库
strCon = CONNECTSTRING + EDIBgbl::sCritPath + strCurDBName;
if( theApp.m_pConnectionCODE->State == adStateOpen )
{
theApp.m_pConnectionCODE->Close();
}
theApp.m_pConnectionCODE->Open(_bstr_t(strCon), "", "", -1);
}
catch(_com_error &e)
{
AfxMessageBox(e.Description()+"\n\n选择的规范数据库("+strCurCodeName+")被破坏, 请重新安装 AutoIPED !");
CDialog::OnCancel();
return;
}
EDIBgbl::sCur_CritDbName = strCurDBName;
EDIBgbl::sCur_CodeName = strCurCodeName;
EDIBgbl::iCur_CodeKey=row+1;
EDIBgbl::SetCurDBName();
//显示当前的工程名(加上行业标准)
((CMainFrame*)theApp.m_pMainWnd)->ShowCurrentProjectName();
CDialog::OnOK();
}
开发者ID:uesoft,项目名称:AutoIPED,代码行数:62,代码来源:DlgSelCritDB.cpp
示例3: StartCmder
void StartCmder(std::wstring path, bool is_single_mode)
{
#if USE_TASKBAR_API
wchar_t appId[MAX_PATH] = { 0 };
#endif
wchar_t exeDir[MAX_PATH] = { 0 };
wchar_t icoPath[MAX_PATH] = { 0 };
wchar_t cfgPath[MAX_PATH] = { 0 };
wchar_t oldCfgPath[MAX_PATH] = { 0 };
wchar_t conEmuPath[MAX_PATH] = { 0 };
wchar_t args[MAX_PATH * 2 + 256] = { 0 };
GetModuleFileName(NULL, exeDir, sizeof(exeDir));
#if USE_TASKBAR_API
wcscpy_s(appId, exeDir);
#endif
PathRemoveFileSpec(exeDir);
PathCombine(icoPath, exeDir, L"icons\\cmder.ico");
// Check for machine-specific config file.
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml");
ExpandEnvironmentStrings(oldCfgPath, oldCfgPath, sizeof(oldCfgPath) / sizeof(oldCfgPath[0]));
if (!PathFileExists(oldCfgPath)) {
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml");
}
// Check for machine-specific config file.
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu-%COMPUTERNAME%.xml");
ExpandEnvironmentStrings(cfgPath, cfgPath, sizeof(cfgPath) / sizeof(cfgPath[0]));
if (!PathFileExists(cfgPath)) {
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
}
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
if (FileExists(oldCfgPath) && !FileExists(cfgPath))
{
if (!CopyFile(oldCfgPath, cfgPath, FALSE))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy ConEmu.xml file to new location! Restart cmder as administrator."
: L"Failed to copy ConEmu.xml file to new location!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
}
if (is_single_mode)
{
swprintf_s(args, L"/single /Icon \"%s\" /Title Cmder", icoPath);
}
else
{
swprintf_s(args, L"/Icon \"%s\" /Title Cmder", icoPath);
}
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
if (!streqi(path.c_str(), L""))
{
if (!SetEnvironmentVariable(L"CMDER_START", path.c_str())) {
MessageBox(NULL, _T("Error trying to set CMDER_START to given path!"), _T("Error"), MB_OK);
}
}
// Ensure EnvironmentVariables are propagated.
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL); // For Windows >= 8
STARTUPINFO si = { 0 };
si.cb = sizeof(STARTUPINFO);
#if USE_TASKBAR_API
si.lpTitle = appId;
si.dwFlags = STARTF_TITLEISAPPID;
#endif
PROCESS_INFORMATION pi;
if (!CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) {
MessageBox(NULL, _T("Unable to create the ConEmu Process!"), _T("Error"), MB_OK);
return;
}
}
开发者ID:1833183060,项目名称:cmder-1,代码行数:83,代码来源:CmderLauncher.cpp
示例4: LogDebug
int Sequence::OpenSequenceFile(const char *filename, int startSeconds) {
LogDebug(VB_SEQUENCE, "OpenSequenceFile(%s, %d)\n", filename, startSeconds);
if (!filename || !filename[0])
{
LogErr(VB_SEQUENCE, "Empty Sequence Filename!\n", filename);
return 0;
}
size_t bytesRead = 0;
m_seqFileSize = 0;
if (IsSequenceRunning())
CloseSequenceFile();
m_seqStarting = 1;
m_seqPaused = 0;
m_seqDuration = 0;
m_seqSecondsElapsed = 0;
m_seqSecondsRemaining = 0;
strcpy(m_seqFilename, filename);
char tmpFilename[2048];
unsigned char tmpData[2048];
strcpy(tmpFilename,(const char *)getSequenceDirectory());
strcat(tmpFilename,"/");
strcat(tmpFilename, filename);
if (getFPPmode() == REMOTE_MODE)
CheckForHostSpecificFile(getSetting("HostName"), tmpFilename);
if (!FileExists(tmpFilename))
{
LogErr(VB_SEQUENCE, "Sequence file %s does not exist\n", tmpFilename);
m_seqStarting = 0;
return 0;
}
m_seqFile = fopen((const char *)tmpFilename, "r");
if (m_seqFile == NULL)
{
LogErr(VB_SEQUENCE, "Error opening sequence file: %s. fopen returned NULL\n",
tmpFilename);
m_seqStarting = 0;
return 0;
}
if (getFPPmode() == MASTER_MODE)
{
SendSeqSyncStartPacket(filename);
// Give the remotes a head start spining up so they are ready
usleep(100000);
}
///////////////////////////////////////////////////////////////////////
// Check 4-byte File format identifier
char seqFormatID[5];
strcpy(seqFormatID, " ");
bytesRead = fread(seqFormatID, 1, 4, m_seqFile);
seqFormatID[4] = 0;
if ((bytesRead != 4) || (strcmp(seqFormatID, "PSEQ") && strcmp(seqFormatID, "FSEQ")))
{
LogErr(VB_SEQUENCE, "Error opening sequence file: %s. Incorrect File Format header: '%s', bytesRead: %d\n",
filename, seqFormatID, bytesRead);
fseek(m_seqFile, 0L, SEEK_SET);
bytesRead = fread(tmpData, 1, DATA_DUMP_SIZE, m_seqFile);
HexDump("Sequence File head:", tmpData, bytesRead);
fclose(m_seqFile);
m_seqFile = NULL;
m_seqStarting = 0;
return 0;
}
///////////////////////////////////////////////////////////////////////
// Get Channel Data Offset
bytesRead = fread(tmpData, 1, 2, m_seqFile);
if (bytesRead != 2)
{
LogErr(VB_SEQUENCE, "Sequence file %s too short, unable to read channel data offset value\n", filename);
fseek(m_seqFile, 0L, SEEK_SET);
bytesRead = fread(tmpData, 1, DATA_DUMP_SIZE, m_seqFile);
HexDump("Sequence File head:", tmpData, bytesRead);
fclose(m_seqFile);
m_seqFile = NULL;
m_seqStarting = 0;
return 0;
}
m_seqChanDataOffset = tmpData[0] + (tmpData[1] << 8);
///////////////////////////////////////////////////////////////////////
// Now that we know the header size, read the whole header in one shot
fseek(m_seqFile, 0L, SEEK_SET);
bytesRead = fread(tmpData, 1, m_seqChanDataOffset, m_seqFile);
//.........这里部分代码省略.........
开发者ID:jcochran,项目名称:fpp,代码行数:101,代码来源:Sequence.cpp
示例5: main
int
main(int argc, char *argv[])
{
char **av, surf_fname[STRLEN], *template_fname, *hemi, *sphere_name,
*cp, *subject, fname[STRLEN] ;
int ac, nargs, ino, sno, nbad = 0, failed, n,nfields;
VERTEX *v;
VALS_VP *vp;
MRI_SURFACE *mris ;
MRI_SP *mrisp, /* *mrisp_aligned,*/ *mrisp_template ;
INTEGRATION_PARMS parms ;
/* rkt: check for and handle version tag */
nargs = handle_version_option
(argc, argv,
"$Id: mris_make_template.c,v 1.27 2011/03/02 00:04:33 nicks Exp $",
"$Name: stable5 $");
if (nargs && argc - nargs == 1)
exit (0);
argc -= nargs;
memset(&parms, 0, sizeof(parms)) ;
Progname = argv[0] ;
ErrorInit(NULL, NULL, NULL) ;
DiagInit(NULL, NULL, NULL) ;
/* setting default values for vectorial registration */
setParms(&parms);
ac = argc ;
av = argv ;
for ( ; argc > 1 && ISOPTION(*argv[1]) ; argc--, argv++)
{
nargs = get_option(argc, argv,&parms) ;
argc -= nargs ;
argv += nargs ;
}
if (argc < 5) usage_exit() ;
/* multiframe registration */
if (multiframes) parms.flags |= IP_USE_MULTIFRAMES;
if (!strlen(subjects_dir)) /* not specified on command line*/
{
cp = getenv("SUBJECTS_DIR") ;
if (!cp)
ErrorExit(ERROR_BADPARM,
"%s: SUBJECTS_DIR not defined in environment.\n",
Progname) ;
strcpy(subjects_dir, cp) ;
}
hemi = argv[1] ;
sphere_name = argv[2] ;
template_fname = argv[argc-1] ;
if (1 || !FileExists(template_fname)) /* first time - create it */
{
fprintf(stderr, "creating new parameterization...\n") ;
if (multiframes)
{
mrisp_template = MRISPalloc(scale, atlas_size * IMAGES_PER_SURFACE );
/* if (no_rot) /\* don't do rigid alignment *\/ */
/* mrisp_aligned = NULL ; */
/* else */
/* mrisp_aligned = MRISPalloc(scale, PARAM_FRAMES); */
}
else
{
mrisp_template = MRISPalloc(scale, PARAM_IMAGES);
/* if (no_rot) /\* don't do rigid alignment *\/ */
/* mrisp_aligned = NULL ; */
/* else */
/* mrisp_aligned = MRISPalloc(scale, PARAM_IMAGES); */
}
}
else
{
fprintf(stderr, "reading template parameterization from %s...\n",
template_fname) ;
/* mrisp_aligned = NULL ; */
mrisp_template = MRISPread(template_fname) ;
if (!mrisp_template)
ErrorExit(ERROR_NOFILE, "%s: could not open template file %s",
Progname, template_fname) ;
}
argv += 3 ;
argc -= 3 ;
for (ino = 0 ; ino < argc-1 ; ino++)
{
failed = 0 ;
subject = argv[ino] ;
fprintf(stderr, "\nprocessing subject %s (%d of %d)\n", subject,
ino+1, argc-1) ;
sprintf(surf_fname, "%s/%s/surf/%s.%s",
subjects_dir, subject, hemi, sphere_name) ;
fprintf(stderr, "reading spherical surface %s...\n", surf_fname) ;
mris = MRISread(surf_fname) ;
if (!mris)
{
//.........这里部分代码省略.........
开发者ID:guo2004131,项目名称:freesurfer,代码行数:101,代码来源:mris_make_template.c
示例6: switch
void __fastcall TForm1::TabControl1Change(TObject *Sender)
{
switch( TabControl1 -> TabIndex )
{
case 0:
{
if( !FileExists( "MeanFile.txt" ) || !FileExists( "standardDeviation.txt" ) )
{
char filename[ 150 ];
MacroBlock MeanBlock[ imageHeight / 16 ][ imageWidth / 16 ];
MacroBlock block[ imageHeight / 16 ][ imageWidth / 16 ];
for( int n = 0; n < FileListBox1 -> Items -> Count; n ++ )
{
memset( block, 0, sizeof( block ) );
memset( MeanBlock, 0, sizeof( MeanBlock ) );
sprintf( filename, "%s%s", ExtractFilePath( FileListBox1 -> FileName ), FileListBox1 -> Items -> Strings[ n ].c_str() );
ReadBMPData( filename );
double LSum = 0;
for( int i = 0; i < imageHeight / 16; i ++ )
for( int j = 0; j < imageWidth / 16; LSum = 0, j ++ )
{
for( int k = i * 16; k <= ( i * 16 + 15 ); k ++ )
for( int m = j * 16 * 3; m <= ( j * 16 + 15 ) * 3; m += 3 )
{
RGB2Lab( ImageDataBlock[ k ][ m + 0 ], ImageDataBlock[ k ][ m + 1 ], ImageDataBlock[ k ][ m + 2 ],
&Lab_buf[ k ][ m + 0 ], &Lab_buf[ k ][ m + 1 ], &Lab_buf[ k ][ m + 2 ] );
LSum += Lab_buf[ k ][ m + 0 ];
}
block[ i ][ j ].DCL = LSum / 256.0;
MeanBlock[ i ][ j ].DCL += block[ i ][ j ].DCL;
AllDCL[ n ][ i ][ j ] = block[ i ][ j ].DCL;
}
}
for( int i = 0; i < imageHeight / 16; i ++ )
for( int j = 0; j < imageWidth / 16; j ++ )
MeanBlock[ i ][ j ].DCL /= FileListBox1 -> Items -> Count;
FILE *MeanFile = fopen( "MeanFile.txt", "w" );
for( int i = 0; i < imageHeight / 16; i ++ )
{
for( int j = 0; j < imageWidth / 16; j ++ )
fprintf( MeanFile, "%f ", MeanBlock[ i ][ j ].DCL );
fprintf( MeanFile, "\n" );
}
fclose( MeanFile );
for( int i = 0; i < 100; i ++ )
for( int j = 0; j < imageHeight / 16; j ++ )
for( int k = 0; k < imageWidth / 16; k ++ )
stddev[ j ][ k ] += pow( AllDCL[ i ][ j ][ k ] - MeanBlock[ j ][ k ].DCL, 2 );
for( int i = 0; i < imageHeight / 16; i ++ )
for( int j = 0; j < imageWidth / 16; j ++ )
stddev[ i ][ j ] = pow( stddev[ i ][ j ] / ( FileListBox1 -> Items -> Count - 1 ), 0.5 );
FILE *StandardDeviation = fopen( "standardDeviation.txt", "w" );
for( int i = 0; i < imageHeight / 16; i ++ )
{
for( int j = 0; j < imageWidth / 16; j ++ )
fprintf( StandardDeviation, "%f ", stddev[ i ][ j ] );
fprintf( StandardDeviation, "\n" );
}
fclose( StandardDeviation );
}
break;
}
}
}
开发者ID:yanhongwang,项目名称:ColorImageProcessingPipeline,代码行数:97,代码来源:Unit1.cpp
示例7: batchmat
/************************************************************************************
* batch use of mkmat: open file, save to another file.... T6spectra.root
*
************************************************************************************
*/
void batchmat(int run, int det=6, const char* VOL="V" ){
// TChain *c=new TChain("nanot");
TString s;
char fname[180];
char fnamespe[180];
char namespe[180];
char telename[30];// T6
char telename1D[30];// T61D - original name
char telenamed[33];// T6d
char telenamep[30];// T6p
char telenamede[30];// T6de
char cutdname[30];// cutt6d
char cutpname[30];// cutt6p
// accept both 003 or 0003......
sprintf( fname, "RUN%03d_%s.root", run, VOL );
if ( FileExists( fname,1000 ) ){
printf("File %s exists\n", fname);
}else{
sprintf( fname, "RUN%04d_%s.root", run, VOL );
}
sprintf( namespe, "T%d_run%03d_%s", det, run, VOL );//spectrum name
sprintf( fnamespe, "T%d%sspectra.root", det, VOL ); //filename
// these names must correspond to mkmat T2V T2V1D
sprintf( telename, "T%d%s", det, VOL ); //telename
sprintf( telename1D, "T%d%s1D", det, VOL ); //telename 1D
sprintf( telenamed, "T%d_d_run%03d_%s", det, run, VOL); //telename d
sprintf( telenamep, "T%d_p_run%03d_%s", det, run, VOL ); //telename p
sprintf( telenamede, "T%d_de_run%03d_%s", det, run, VOL ); //telename de
sprintf( cutdname, "cutt%dd%s", det, VOL ); //cutname d
sprintf( cutpname, "cutt%dp%s", det, VOL ); //cutname p
/*
* READ THE FOLLOWING ROOT FILE-----------------------------------------
*/
if ( ! FileExists( fname,1000 ) ){// FILE root DOES EXIST..................
printf("file %s doesnot exist or is zombie\n", fname );
}else{
printf("file %s exists OK\n", fname );
TFile *f=new TFile( fname ,"READ"); // read from
TTree *t=(TTree*)f->Get("nanot");
/*
* CREATE MATRIX (and d and p spectra as well?)
*/
mkmat( det, VOL );
TH2F* t6bi=(TH2F*)gDirectory->Get( telename );
/*
* CREATE 1DIM (and d and p spectra as well?)
*/
printf( "searching for TCutG : %s, %s\n", cutdname, cutpname );
TCutG *mycutd=(TCutG*)gROOT->GetListOfSpecials()->FindObject( cutdname );
TCutG *mycutp=(TCutG*)gROOT->GetListOfSpecials()->FindObject( cutpname );
TH1F* t61d_d;
TH1F* t61d_p;
TH1F* t61d_de;
/*
* if there are cuts ==>> create 1D
*/
if (mycutd!=NULL){
mkmat1( det, VOL, mycutd ); // create 1D
t61d_d=(TH1F*)gDirectory->Get( telename1D );
t61d_d->SetName( telenamed );
}//cutd
if (mycutp!=NULL){
mkmat1( det, VOL, mycutp ); // create 1D
t61d_p=(TH1F*)gDirectory->Get( telename1D );
t61d_p->SetName( telenamep );
}//cutd
// Run with a condition:
// MAKE 1D dE ONLY SPECTRUM
mkmat1( -det , VOL, "e<10" ); // and now see.... only dE plotted; reverse
t61d_de=(TH1F*)gDirectory->Get( telename1D );
t61d_de->SetName( telenamede );
// SAVE .................................................
TDirectory *dir=gDirectory;
TFile *f2=new TFile( fnamespe ,"UPDATE"); // save to ...fnamespe...Tispectra.root
t6bi->SetName( namespe );
//.........这里部分代码省略.........
开发者ID:jaromrax,项目名称:mkmat,代码行数:101,代码来源:mkmat_18876_22ne.C
示例8: main
int main(int argc, char * arg[])
{
printf("DBC/Map Extractor\n");
printf("===================\n\n");
bool extractDBC = true;
bool extractMap = true;
for (int i = 0; i < argc; ++i)
{
if (strcmp(arg[i], ARG_MAP) == 0)
extractMap = true;
if (strcmp(arg[i], ARG_NOMAP) == 0)
extractMap = false;
if (strcmp(arg[i], ARG_DBC) == 0)
extractDBC = true;
if (strcmp(arg[i], ARG_NODBC) == 0)
extractDBC = false;
}
int FirstLocale = -1;
int build = 0;
for (int i = 0; i < LANG_COUNT; i++)
{
char tmp1[512];
sprintf(tmp1, "%s/Data/%s/locale-%s.MPQ", input_path, langs[i], langs[i]);
if (FileExists(tmp1))
{
printf("Detected locale: %s\n", langs[i]);
//Open MPQs
LoadLocaleMPQFiles(i);
//Extract DBC files
if (FirstLocale < 0)
{
FirstLocale = i;
build = ReadBuild(FirstLocale);
printf("Detected base client build: %u\n", build);
if (build != CLIENT_BUILD)
{
printf("ERROR: your client is not up-to-date. Client build should be %u", CLIENT_BUILD);
return 0;
}
if (extractDBC)
ExtractDBCFiles(i, true);
}
else if (extractDBC)
ExtractDBCFiles(i, false);
}
}
if (FirstLocale < 0)
{
printf("No locales detected\n");
return 0;
}
if (extractMap)
ExtractMapsFromMpq(build);
return 0;
}
开发者ID:SkyFireArchives,项目名称:SkyFireEMU_406a,代码行数:64,代码来源:main.cpp
示例9: Date
void __fastcall TReportForm::ToolButton3Click(TObject *Sender)
{
Variant WordApp, WordSel, WordDoc, EmptyParam, table, cell, range;
TDateTime dtReport = Date();
UnicodeString s=ExtractFileDir(Application->ExeName)+"\\template.doc";
if (!FileExists(s)) {
ShowMessage("Файл шаблона не найден");
return;
}
TVirtualNode *t_root=VirtualStringTree1->RootNode->FirstChild;
TVirtualNode *t_child;
TReportData *data_root, *data_child;
try {
WordApp=GetActiveOleObject("Word.Application");
} catch (...) {
try {
WordApp=CreateOleObject("Word.Application");
} catch (...) {
ShowMessage("Microsoft Word не установлен");
return;
}
}
try {
WordApp.OlePropertySet("Visible", false);
WordDoc=WordApp.OlePropertyGet("Documents").OleFunction("Add", s.t_str());
// if (WordDoc.OlePropertyGet("Bookmarks").OleFunction("Exists", "date"))
// ShowMessage("!");
// WordDoc.OleFunction("GoTo", 0xFFFFFFFF, EmptyParam, EmptyParam, "date").OleFunction("Select");
WordApp.OlePropertyGet("Selection").OleFunction("goto", 0xFFFFFFFF, EmptyParam, EmptyParam, "date");
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", dtReport.FormatString("dd.mm.yyyy").t_str());
WordApp.OlePropertyGet("Selection").OleFunction("goto", 0xFFFFFFFF, EmptyParam, EmptyParam, "img");
MainForm->Chart5->CopyToClipboardMetafile(true);
WordApp.OlePropertyGet("Selection").OleFunction("Paste");
WordApp.OlePropertyGet("Selection").OleFunction("goto", 0xFFFFFFFF, EmptyParam, EmptyParam, "table");
// table=WordDoc.OlePropertyGet("Tables").OleFunction("Item", 1);
// cell=table.OleFunction("Cell", 1, 1);
// range=cell.OlePropertyGet("Range");
// range.OlePropertySet("Text", "Fuck");
for (size_t i=0; i < VirtualStringTree1->RootNodeCount; i++) {
if (!(t_root == NULL)) {
data_root=(TReportData *)ReportForm->VirtualStringTree1->GetNodeData(t_root);
if (!(data_root == NULL)) {
s=data_root->Name;
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", s.t_str());
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
}
else
continue;
t_child=t_root->FirstChild;
while (!(t_child == NULL))
{
data_child=(TReportData *)ReportForm->VirtualStringTree1->GetNodeData(t_child);
if (!(data_child == NULL) && (t_child->CheckState == csCheckedNormal)) {
s=data_child->Name;
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", s.t_str());
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", FloatToStrF(data_child->pcs, ffFixed, 5, 2).t_str());
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", FloatToStrF(data_child->pi, ffFixed, 5, 2).t_str());
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", FloatToStr(data_child->angle).t_str());
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
}
t_child=t_child->NextSibling;
}
WordApp.OlePropertyGet("Selection").OlePropertyGet("Font").OlePropertySet("Bold", true);
WordApp.OlePropertyGet("Selection").OlePropertyGet("ParagraphFormat").OlePropertySet("Alignment", 0);
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", "Средний диаметр");
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OlePropertyGet("Font").OlePropertySet("Bold", false);
WordApp.OlePropertyGet("Selection").OlePropertyGet("ParagraphFormat").OlePropertySet("Alignment", 1);
s=FloatToStrF(data_root->pcs, ffFixed, 5, 2)+" нм.";
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", s.t_str());
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", "Средний ППД");
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", FloatToStrF(data_root->pi, ffFixed, 5, 2).t_str());
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
//.........这里部分代码省略.........
开发者ID:aquatter,项目名称:DLS-App-test,代码行数:101,代码来源:UReportForm.cpp
示例10: InjectRemote
int InjectRemote(DWORD nRemotePID, bool abDefTermOnly /*= false */)
{
int iRc = -1;
bool lbWin64 = WIN3264TEST((IsWindows64()!=0),true);
bool is32bit;
DWORD nWrapperWait = (DWORD)-1, nWrapperResult = (DWORD)-1;
HANDLE hProc = NULL;
wchar_t szSelf[MAX_PATH+16], szHooks[MAX_PATH+16];
wchar_t *pszNamePtr, szArgs[32];
if (!GetModuleFileName(NULL, szSelf, MAX_PATH))
{
iRc = -200;
goto wrap;
}
wcscpy_c(szHooks, szSelf);
pszNamePtr = (wchar_t*)PointToName(szHooks);
if (!pszNamePtr)
{
iRc = -200;
goto wrap;
}
hProc = OpenProcess(PROCESS_CREATE_THREAD|PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ, FALSE, nRemotePID);
if (hProc == NULL)
{
iRc = -201;
goto wrap;
}
// Определить битность процесса, Если он 32битный, а текущий - ConEmuC64.exe
// Перезапустить 32битную версию ConEmuC.exe
if (!lbWin64)
{
is32bit = true; // x86 OS!
}
else
{
is32bit = false; // x64 OS!
// Проверяем, кто такой nRemotePID
HMODULE hKernel = GetModuleHandleW(L"kernel32.dll");
if (hKernel)
{
typedef BOOL (WINAPI* IsWow64Process_t)(HANDLE hProcess, PBOOL Wow64Process);
IsWow64Process_t IsWow64Process_f = (IsWow64Process_t)GetProcAddress(hKernel, "IsWow64Process");
if (IsWow64Process_f)
{
BOOL bWow64 = FALSE;
if (IsWow64Process_f(hProc, &bWow64) && bWow64)
{
// По идее, такого быть не должно. ConEmu должен был запустить 32битный conemuC.exe
#ifdef _WIN64
_ASSERTE(bWow64==FALSE);
#endif
is32bit = true;
}
}
}
}
if (is32bit != WIN3264TEST(true,false))
{
// По идее, такого быть не должно. ConEmu должен был запустить соответствующий conemuC*.exe
_ASSERTE(is32bit == WIN3264TEST(true,false));
PROCESS_INFORMATION pi = {};
STARTUPINFO si = {sizeof(si)};
_wcscpy_c(pszNamePtr, 16, is32bit ? L"ConEmuC.exe" : L"ConEmuC64.exe");
_wsprintf(szArgs, SKIPLEN(countof(szArgs)) L" /INJECT=%u", nRemotePID);
if (!CreateProcess(szHooks, szArgs, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
iRc = -202;
goto wrap;
}
nWrapperWait = WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &nWrapperResult);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
if ((nWrapperResult != CERR_HOOKS_WAS_SET) && (nWrapperResult != CERR_HOOKS_WAS_ALREADY_SET))
{
iRc = -203;
SetLastError(nWrapperResult);
goto wrap;
}
// Значит всю работу сделал враппер
iRc = 0;
goto wrap;
}
// Поехали
_wcscpy_c(pszNamePtr, 16, is32bit ? L"ConEmuHk.dll" : L"ConEmuHk64.dll");
if (!FileExists(szHooks))
{
iRc = -250;
goto wrap;
//.........这里部分代码省略.........
开发者ID:alexlav,项目名称:conemu,代码行数:101,代码来源:InjectRemote.cpp
示例11: table
/** check that parameter settings make sense */
bool Parameter::Validate()
{
bool noErrorFlag = true;
PARAM_MAP::const_iterator iterParams;
for (iterParams = m_setting.begin(); iterParams != m_setting.end(); ++iterParams) {
const std::string &key = iterParams->first;
if (m_valid.find(key) == m_valid.end())
{
UserMessage::Add("Unknown parameter " + key);
noErrorFlag = false;
}
}
// required parameters
if (m_setting["ttable-file"].size() == 0) {
UserMessage::Add("No phrase translation table (ttable-file)");
noErrorFlag = false;
}
if (m_setting["lmodel-dub"].size() > 0) {
if (m_setting["lmodel-file"].size() != m_setting["lmodel-dub"].size()) {
stringstream errorMsg("");
errorMsg << "Config and parameters specify "
<< static_cast<int>(m_setting["lmodel-file"].size())
<< " language model files (lmodel-file), but "
<< static_cast<int>(m_setting["lmodel-dub"].size())
<< " LM upperbounds (lmodel-dub)"
<< endl;
UserMessage::Add(errorMsg.str());
noErrorFlag = false;
}
}
if (m_setting["lmodel-file"].size() * (m_setting.find("lmodel-oov-feature") != m_setting.end() ? 2 : 1)
!= m_setting["weight-l"].size()) {
stringstream errorMsg("");
errorMsg << "Config and parameters specify "
<< static_cast<int>(m_setting["lmodel-file"].size())
<< " language model files (lmodel-file), but "
<< static_cast<int>(m_setting["weight-l"].size())
<< " weights (weight-l)";
errorMsg << endl << "You might be giving '-lmodel-file TYPE FACTOR ORDER FILENAME' but you should be giving these four as a single argument, i.e. '-lmodel-file \"TYPE FACTOR ORDER FILENAME\"'";
errorMsg << endl << "You should also remember that each language model requires 2 weights, if and only if lmodel-oov-feature is on.";
UserMessage::Add(errorMsg.str());
noErrorFlag = false;
}
// do files exist?
// input file
if (noErrorFlag && m_setting["input-file"].size() == 1) {
noErrorFlag = FileExists(m_setting["input-file"][0]);
}
// generation tables
if (noErrorFlag) {
std::vector<std::string> ext;
//raw tables in either un compressed or compressed form
ext.push_back("");
ext.push_back(".gz");
noErrorFlag = FilesExist("generation-file", 3, ext);
}
// distortion
if (noErrorFlag) {
std::vector<std::string> ext;
//raw tables in either un compressed or compressed form
ext.push_back("");
ext.push_back(".gz");
//prefix tree format
ext.push_back(".binlexr.idx");
noErrorFlag = FilesExist("distortion-file", 3, ext);
}
return noErrorFlag;
}
开发者ID:CUNI-Khresmoi,项目名称:CUNI-Khresmoi-Moses,代码行数:77,代码来源:Parameter.cpp
示例12: PrepareHookModule
int PrepareHookModule(wchar_t (&szModule)[MAX_PATH+16])
{
int iRc = -251;
wchar_t szNewPath[MAX_PATH+16] = {}, szAddName[32] = {}, szVer[2] = {};
INT_PTR nLen = 0;
bool bAlreadyExists = false;
// Copy szModule to CSIDL_LOCAL_APPDATA and return new path
HRESULT hr = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szNewPath);
if ((hr != S_OK) || !*szNewPath)
{
iRc = -251;
goto wrap;
}
szVer[0] = MVV_4a[0];
_wsprintf(szAddName, SKIPLEN(countof(szAddName))
L"\\" CEDEFTERMDLLFORMAT /*L"ConEmuHk%s.%02u%02u%02u%s.dll"*/,
WIN3264TEST(L"",L"64"), MVV_1, MVV_2, MVV_3, szVer);
nLen = lstrlen(szNewPath);
if (szNewPath[nLen-1] != L'\\')
{
szNewPath[nLen++] = L'\\'; szNewPath[nLen] = 0;
}
if ((nLen + lstrlen(szAddName) + 8) >= countof(szNewPath))
{
iRc = -252;
goto wrap;
}
wcscat_c(szNewPath, L"ConEmu");
if (!DirectoryExists(szNewPath))
{
if (!CreateDirectory(szNewPath, NULL))
{
iRc = -253;
goto wrap;
}
}
wcscat_c(szNewPath, szAddName);
if ((bAlreadyExists = FileExists(szNewPath)) && FileCompare(szNewPath, szModule))
{
// OK, file exists and match the required
}
else
{
if (bAlreadyExists)
{
_ASSERTE(FALSE && "Continue to overwrite existing ConEmuHk in AppLocal");
// Try to delete or rename old version
if (!DeleteFile(szNewPath))
{
//SYSTEMTIME st; GetLocalTime(&st);
wchar_t szBakPath[MAX_PATH+32]; wcscpy_c(szBakPath, szNewPath);
wchar_t* pszExt = (wchar_t*)PointToExt(szBakPath);
msprintf(pszExt, 16, L".%u.dll", GetTickCount());
DeleteFile(szBakPath);
MoveFile(szNewPath, szBakPath);
}
}
if (!CopyFile(szModule, szNewPath, FALSE))
{
iRc = -254;
goto wrap;
}
}
wcscpy_c(szModule, szNewPath);
iRc = 0;
wrap:
return iRc;
}
开发者ID:alexlav,项目名称:conemu,代码行数:78,代码来源:InjectRemote.cpp
示例13: CreateChecksumFiles_OnePerDir
/*****************************************************************************
static DWORD CreateChecksumFiles_OnePerDir(CONST UINT uiMode,CONST TCHAR szChkSumFilename[MAX_PATH_EX], list<FILEINFO*> *finalList)
uiMode : (IN) create MD5 or SFV files
szChkSumFilename: (IN) filename without path
finalList : (IN) pointer to list of fileinfo pointers on which the action is to be performed
Return Value:
returns NOERROR or GetLastError()
Notes:
- handles the situation if the user want one sfv/md5 file per directory. In every directory
a file with the name szChkSumFilename is created
*****************************************************************************/
static DWORD CreateChecksumFiles_OnePerDir(CONST UINT uiMode,CONST TCHAR szChkSumFilename[MAX_PATH_EX], list<FILEINFO*> *finalList)
{
DWORD dwResult;
TCHAR szCurrentDir[MAX_PATH_EX];
TCHAR szCurChecksumFilename[MAX_PATH_EX];
TCHAR szPreviousDir[MAX_PATH_EX] = TEXT("?:><"); // some symbols that are not allowed in filenames to force
// the checksum file creation in the for loop
HANDLE hFile = NULL;
for(list<FILEINFO*>::iterator it=finalList->begin();it!=finalList->end();it++) {
if( (*it)->dwError == NO_ERROR ){
StringCchCopy(szCurrentDir, MAX_PATH_EX, (*it)->szFilename);
ReduceToPath(szCurrentDir);
if(lstrcmpi(szPreviousDir, szCurrentDir) != 0){
if(hFile) {
CloseHandle(hFile);
hFile = NULL;
}
StringCchCopy(szPreviousDir, MAX_PATH_EX, szCurrentDir);
StringCchPrintf(szCurChecksumFilename, MAX_PATH_EX, TEXT("%s%s"), szCurrentDir, szChkSumFilename);
if(g_program_options.bNoHashFileOverride && FileExists(szCurChecksumFilename)) {
continue;
}
hFile = CreateFile(szCurChecksumFilename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, NULL);
if(hFile == INVALID_HANDLE_VALUE){
return GetLastError();
}
#ifdef UNICODE
// we need a BOM if we are writing unicode
if(!WriteCurrentBOM(hFile))
return GetLastError();
#endif
if( (uiMode == MODE_SFV) && g_program_options.bWinsfvComp){
dwResult = WriteSfvHeader(hFile);
if(dwResult != NOERROR){
CloseHandle(hFile);
return dwResult;
}
}
if(g_program_options.bIncludeFileComments) {
list<FILEINFO*>::iterator commentIt = it;
do
{
if((*commentIt)->dwError == NO_ERROR) {
WriteFileComment(hFile, (*commentIt), (UINT)(GetFilenameWithoutPathPointer((*commentIt)->szFilenameShort) - (*commentIt)->szFilename));
}
commentIt++;
if(commentIt == finalList->end())
break;
StringCchCopy(szCurrentDir, MAX_PATH_EX, (*commentIt)->szFilename);
ReduceToPath(szCurrentDir);
}
while(lstrcmpi(szPreviousDir, szCurrentDir) == 0);
}
}
if(hFile) {
dwResult = WriteHashLine(hFile, GetFilenameWithoutPathPointer((*it)->szFilenameShort),
(*it)->hashInfo[uiMode].szResult, uiMode == MODE_SFV);
if(dwResult != NOERROR){
CloseHandle(hFile);
return dwResult;
}
}
}
}
CloseHandle(hFile);
return NOERROR;
}
开发者ID:andrew-tpfc,项目名称:RapidCRC-Unicode,代码行数:85,代码来源:actfcts.cpp
示例14: DoInstallFiles
///////////////////////////////////////////////////////////////
//
// DoInstallFiles
//
// Copy directory tree at current dirctory to GetMTASAPath ()
//
///////////////////////////////////////////////////////////////
bool DoInstallFiles ( void )
{
SString strCurrentDir = PathConform ( GetSystemCurrentDirectory () );
const SString strMTASAPath = PathConform ( GetMTASAPath () );
SString path1, path2;
strCurrentDir.Split ( "\\", &path1, &path2, -1 );
SString strDestRoot = strMTASAPath;
SString strSrcRoot = strCurrentDir;
SString strBakRoot = MakeUniquePath ( strCurrentDir + "_bak_" );
// Clean backup dir
if ( !MkDir ( strBakRoot ) )
{
AddReportLog ( 5020, SString ( "InstallFiles: Couldn't make dir '%s'", strBakRoot.c_str () ) );
return false;
}
// Get list of files to install
std::vector < SFileItem > itemList;
{
std::vector < SString > fileList;
FindFilesRecursive ( PathJoin ( strCurrentDir, "*" ), fileList );
for ( unsigned int i = 0 ; i < fileList.size () ; i++ )
{
SFileItem item;
item.strSrcPathFilename = PathConform ( fileList[i] );
item.strDestPathFilename = PathConform ( fileList[i].Replace ( strSrcRoot, strDestRoot ) );
item.strBackupPathFilename = PathConform ( fileList[i].Replace ( strSrcRoot, strBakRoot ) );
itemList.push_back ( item );
}
}
// See if any files to be updated are running.
// If so, terminate them
for ( unsigned int i = 0 ; i < itemList.size () ; i++ )
{
SString strFile = itemList[i].strDestPathFilename;
if ( strFile.EndsWithI( ".exe" ) )
TerminateProcessFromPathFilename ( strFile );
}
// Copy current(old) files into backup location
for ( unsigned int i = 0 ; i < itemList.size () ; i++ )
{
const SFileItem& item = itemList[i];
if ( !FileCopy ( item.strDestPathFilename, item.strBackupPathFilename ) )
{
if ( FileExists ( item.strDestPathFilename ) )
{
AddReportLog ( 5021, SString ( "InstallFiles: Couldn't backup '%s' to '%s'", *item.strDestPathFilename, *item.strBackupPathFilename ) );
return false;
}
AddReportLog ( 4023, SString ( "InstallFiles: Couldn't backup '%s' as it does not exist", *item.strDestPathFilename ) );
}
}
// Try copy new files
bool bOk = true;
std::vector < SFileItem > fileListSuccess;
for ( unsigned int i = 0 ; i < itemList.size () ; i++ )
{
const SFileItem& item = itemList[i];
if ( !FileCopy ( item.strSrcPathFilename, item.strDestPathFilename ) )
{
// If copy failed, check if we really need to copy the file
if ( GenerateSha256HexStringFromFile( item.strSrcPathFilename ) != GenerateSha256HexStringFromFile( item.strDestPathFilename ) )
{
AddReportLog ( 5022, SString ( "InstallFiles: Couldn't copy '%s' to '%s'", *item.strSrcPathFilename, *item.strDestPathFilename ) );
bOk = false;
break;
}
}
fileListSuccess.push_back ( item );
}
// If fail, copy back old files
if ( !bOk )
{
bool bPossibleDisaster = false;
for ( unsigned int i = 0 ; i < fileListSuccess.size () ; i++ )
{
const SFileItem& item = fileListSuccess[i];
int iRetryCount = 3;
while ( true )
{
if ( FileCopy ( item.strBackupPathFilename, item.strDestPathFilename ) )
break;
// If copy failed, check if we really need to copy the file
if ( GenerateSha256HexStringFromFile( item.strBackupPathFilename ) != GenerateSha256HexStringFromFile( item.strDestPathFilename ) )
//.........这里部分代码省略.........
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:101,代码来源:Install.cpp
|
请发表评论