Esempio n. 1
0
//#define MAX_SECTORS_COUNT 4096
//#define MAX_BLOCK_SIZE MAX_SECTORS_COUNT * 1024
void CMapBlocks::DeterminateBlock(int iMinSector)
{
	m_pFileCreater->setDirectoryPath(m_strDirctoryPath);
	UINT iCurrentFile = 1;
	auto setting = settings::CSettings::getSetting();
	DWORD max_sector_count = setting->getMaxBlock() / m_vecDrives.at(0).getBytesPerSector();//???
	if (m_dwBlockSize == 0)
	{
		//int iMinBlock
		int iStartBlock = 1;
		for (UINT iBlock = 1 ; iBlock <= max_sector_count; iBlock *= 2 )
		{
			if ( (iMinSector / iBlock) <= 1 )
			{
				iStartBlock = iBlock;
				break;
			}
		}
		DWORD blockSize = iStartBlock*m_vecDrives.at(0).getBytesPerSector();//???
		while ( blockSize <= setting->getMaxBlock() )
		{
			CreateFiles(iCurrentFile,blockSize,m_iNextDisk);
			blockSize *= 2;
		}
	}
	else
		CreateFiles(iCurrentFile,m_dwBlockSize);
}
Esempio n. 2
0
void VcImporter::CreateFiles(wxXmlNode* parent, wxString vdPath, ProjectPtr proj)
{
    if(!parent) {
        return;
    }

    wxXmlNode* child = parent->GetChildren();
    while(child) {
        if(child->GetName() == wxT("Filter")) {
            // add new virtual directory
            wxString name = XmlUtils::ReadString(child, wxT("Name"));
            wxString tmpPath = vdPath;
            if(tmpPath.IsEmpty() == false) {
                tmpPath << wxT(":");
            }
            tmpPath << name;
            proj->CreateVirtualDir(tmpPath);
            CreateFiles(child, tmpPath, proj);

        } else if(child->GetName() == wxT("File")) {
            // found a file
            wxString fileName = XmlUtils::ReadString(child, wxT("RelativePath"));
            wxString path = vdPath;
            if(path.IsEmpty()) {
                path = wxT("src");
            }

            fileName.Replace(wxT("\\"), wxT("/"));
            proj->AddFile(fileName, path);
        }
        child = child->GetNext();
    }
}
Esempio n. 3
0
/*===========================================================================
 *
 * Class CNifCopyDlg Event - void OnNifcopyCreate ();
 *
 *=========================================================================*/
void CNifCopyDlg::OnNifcopyCreate() {
  CString Buffer;
  bool    Result;

	/* Update the current control data */
  GetControlData();

	/* Check the data */
  Result = CheckData();
  
  if (!Result) {
    ErrorHandler.Notify(_T("Csv Check Failed!"));
    return;
   }

	/* Update the copy information */
  CreateCopyInfos();

	/* Attempt to create the nif files */
  Result = CreateFiles();
  
  if (!Result) {
    ErrorHandler.Notify(_T("Nif Copy Failed!"));
    return;
   }

  Buffer.Format(_T("Successfully created %d NIF files!"), m_CreatedFiles);
  MessageBox(Buffer, _T("NIF Copy Success!"), MB_OK | MB_ICONINFORMATION);
  EndDialog(IDOK);
 }
Esempio n. 4
0
void TopologyWriter::Reset(void) {
  if (shapefileopen) {
    Close();
  }

  DeleteFiles();
  CreateFiles();

  Open();
}
Esempio n. 5
0
/********************************* M A I N ********************************/
int main (
	int argc,
	char **argv
) {
	char		**newargs = NULL;
	LST_LIST	*configlist;
	ConfigType	*config;
	int  		 status = TRUE;

	printf ("MakeScan (c) Echidna 1990\n");

	if (!(argc == 2 && argv[1][0] == '?' && argv[1][1] == '\0')) {
		newargs = argparse (argc, argv, Template);
	}
	if (!newargs) {
		if (GlobalErrMsg) {
			printf ("%s\n", GlobalErrMsg);
		}
		printarghelp (Usage, Template);
	} else {
		DebugSwitch = (int  )((long)newargs[ARG_DEBUG]);
		if ((configlist = ReadConfigurationFile (newargs[ARG_CONFIG]))) {
			if (DebugSwitch) {
				PrintConfigList (configlist);
			}
			if (newargs[ARG_RULE]) {
				strupr (newargs[ARG_RULE]);
				if (!(config = (ConfigType*)LST_FindName (configlist, newargs[ARG_RULE]))) {
					SetGlobalErr (ERR_GENERIC);
					GEprintf1 ("No such rule '%s'", newargs[ARG_RULE]);
					status = FALSE;
				}
			} else {
				config = (ConfigType*)LST_Head (configlist);
			}
			if (status) {
				if (!CreateFiles (config, newargs[ARG_MAKEFILE])) {
					status = FALSE;
				}
			}
		} else {
			status = FALSE;
		}

		if (GlobalErr) {
			printf ("%s\n", GlobalErrMsg);
			status = FALSE;
		}
	}
	return (status ? 0 : 20);
}
Esempio n. 6
0
int main(char **argv, int argc)
{
	long long CHANGE_FILE_NAME   = 0x00000001;
	long long CHANGE_DIR_NAME    = 0x00000002;
	long long CHANGE_ATTRIBUTES  = 0x00000004;
	long long CHANGE_SIZE        = 0x00000008;
	long long CHANGE_LAST_WRITE  = 0x00000010;
	long long CHANGE_LAST_ACCESS = 0x00000020;
	long long CHANGE_CREATION    = 0x00000040;
	long long CHANGE_SECURITY    = 0x00000100;

	Win32FSHook *hook = new Win32FSHook();
	hook->init(callback);
	Sleep(1000);
	DWORD error;
	int w[NWATCHES];
//	Sleep(3000);
	printf("adding watches\n");fflush(stdout);
	for(size_t i =0;i<sizeof(w) / sizeof(int);i++)
	{
		wchar_t b[1000];
		swprintf(b, L"%ls%d",L"c:\\Users\\omry\\tmp\\", i);
		CreateDirectoryW(b, 0);
		w[i] = hook->add_watch(b, CHANGE_SECURITY
				| CHANGE_CREATION
				| CHANGE_LAST_ACCESS
				| CHANGE_LAST_WRITE
				| CHANGE_SIZE
				| CHANGE_ATTRIBUTES
				| CHANGE_DIR_NAME
				| CHANGE_FILE_NAME,
				true,
				error);
		CreateFiles(b, NFILES);
	}

	Sleep(1000);
	printf("removing watches\n");fflush(stdout);
	for(size_t i =0;i<sizeof(w) / sizeof(int);i++)
	{
		hook->remove_watch(w[i]);
	}

	printf("removed\n");fflush(stdout);
	printf("c1 : %d, c2 = %d, c3 = %d\n", c1, c2 ,c3);fflush(stdout);
//	printf("deleting Win32FSHook\n");fflush(stdout);
//	delete hook;.
//	printf("deleted\n");fflush(stdout);
}
void DIALOG_GEN_MODULE_POSITION::OnOKButton( wxCommandEvent& event )
{
    m_unitsOpt = m_radioBoxUnits->GetSelection();
    m_fileOpt = m_radioBoxFilesCount->GetSelection();

    // Set output directory and replace backslashes with forward ones
    // (Keep unix convention in cfg files)
    wxString dirStr;
    dirStr = m_outputDirectoryName->GetValue();
    dirStr.Replace( wxT( "\\" ), wxT( "/" ) );

    m_plotOpts.SetOutputDirectory( dirStr );

    m_parent->SetPlotSettings( m_plotOpts );

    CreateFiles();
}
Esempio n. 8
0
int main (int argc, char * argv[])
{
	if (argc>1) 
	{
		if (strcmp(argv[1],"-h")==0)
		{
			Help();
			return 0;
		}
		else 
		{
			puts("Error. Improper parameter.");
			return 0;
		}
	}
	FILE * binFile = NULL, * txtFile = NULL;
	int bin_numbers = 0;
	int txt_numbers = 0;
	while (1)
	{
		puts("1 - Create both files\n2 - Perform delete operations\n0 - Exit");
		int inp; if (!GetInt(&inp)) 
		{
			puts("Input error. Try again");
			continue;
		}
		switch (inp)
		{
			default:
			puts("Input error. Try again");
			continue;
			case 0:
			return EXIT_SUCCESS;
			case 1: 
			CreateFiles(txtFile, binFile, &txt_numbers, &bin_numbers);
			break;
			case 2:
			DeleteOperations(binFile, txtFile, txt_numbers, bin_numbers);
			break;
		}
	}
}
void DIALOG_GEN_MODULE_POSITION::OnOKButton( wxCommandEvent& event )
{
    m_unitsOpt = m_radioBoxUnits->GetSelection();
    m_fileOpt = m_radioBoxFilesCount->GetSelection();
    m_fileFormat = m_rbFormat->GetSelection();


    m_config->Write( PLACEFILE_UNITS_KEY, m_unitsOpt );
    m_config->Write( PLACEFILE_OPT_KEY, m_fileOpt );
    m_config->Write( PLACEFILE_FORMAT_KEY, m_fileFormat );

    // Set output directory and replace backslashes with forward ones
    // (Keep unix convention in cfg files)
    wxString dirStr;
    dirStr = m_outputDirectoryName->GetValue();
    dirStr.Replace( wxT( "\\" ), wxT( "/" ) );

    m_plotOpts.SetOutputDirectory( dirStr );
    m_parent->SetPlotSettings( m_plotOpts );

    CreateFiles();

    // the dialog is not closed here.
}
Esempio n. 10
0
bool VcImporter::ConvertProject(VcProjectData& data)
{
    wxXmlDocument doc(data.filepath);
    if(!doc.IsOk()) {
        return false;
    }

    // to create a project skeleton, we need the project type
    // since VS allows each configuration to be of different
    // type, while LE allows single type for all configurations
    // we use the first configuration type that we find
    wxXmlNode* configs = XmlUtils::FindFirstByTagName(doc.GetRoot(), wxT("Configurations"));
    if(!configs) {
        return false;
    }

    // find the first configuration node
    wxXmlNode* config = XmlUtils::FindFirstByTagName(configs, wxT("Configuration"));
    if(!config) return false;
    // read the configuration type, default is set to Executeable
    long type = XmlUtils::ReadLong(config, wxT("ConfigurationType"), 1);
    wxString projectType;
    wxString errMsg;
    switch(type) {
    case 2: // dll
        projectType = Project::DYNAMIC_LIBRARY;
        break;
    case 4: // static library
        projectType = Project::STATIC_LIBRARY;
        break;
    case 1: // exe
    default:
        projectType = Project::EXECUTABLE;
        break;
    }
    // now we can create the project
    wxFileName fn(data.filepath);
    fn.MakeAbsolute();
    if(!WorkspaceST::Get()->CreateProject(data.name, fn.GetPath(), projectType, true, errMsg)) {
        return false;
    }

    // get the new project instance
    ProjectPtr proj = WorkspaceST::Get()->FindProjectByName(data.name, errMsg);
    ProjectSettingsPtr le_settings(new ProjectSettings(NULL));
    // remove the default 'Debug' configuration
    le_settings->RemoveConfiguration(wxT("Debug"));
    le_settings->SetProjectType(projectType);

    while(config) {
        if(config->GetName() == wxT("Configuration")) {
            AddConfiguration(le_settings, config);
        }
        config = config->GetNext();
    }
    proj->SetSettings(le_settings);
    // add all virtual folders
    wxXmlNode* files = XmlUtils::FindFirstByTagName(doc.GetRoot(), wxT("Files"));
    if(files) {
        proj->BeginTranscation();
        CreateFiles(files, wxEmptyString, proj);
        proj->CommitTranscation();
    }
    return true;
}
Esempio n. 11
0
void main()
{ CreateFiles();
  HZIP hz; DWORD writ;

  // EXAMPLE 1 - create a zipfile from existing files
  hz = CreateZip(_T("\\simple1.zip"),0);
  ZipAdd(hz,_T("znsimple.bmp"), _T("\\simple.bmp"));
  ZipAdd(hz,_T("znsimple.txt"), _T("\\simple.txt"));
  CloseZip(hz);
  _tprintf(_T("Created '\\simple1.zip'\n"));


  // EXAMPLE 2 - unzip it with the names suggested in the zip
  hz = OpenZip(_T("\\simple1.zip"),0);
  SetUnzipBaseDir(hz,_T("\\"));
  ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;
  for (int zi=0; zi<numitems; zi++)
  { GetZipItem(hz,zi,&ze);
    UnzipItem(hz,zi,ze.name);
  }
  CloseZip(hz);
  _tprintf(_T("Unzipped 'znsimple.bmp' and 'znsimple.txt' from 'simple1.zip'\n"));



  // EXAMPLE 3 - create an auto-allocated pagefile-based zip file from various sources
  // the second argument says how much address space to reserve for it. We can
  // afford to be generous: no address-space is allocated unless it's actually needed.
  hz = CreateZip(0,100000,"password");
  // adding a conventional file...
  ZipAdd(hz,_T("znsimple.txt"),  _T("\\simple.txt"));
  // adding something from memory...
  char buf[1000]; for (int zj=0; zj<1000; zj++) buf[zj]=(char)(zj&0x7F);
  ZipAdd(hz,_T("simple.dat"),  buf,1000);
  // adding something from a pipe...
#ifndef UNDER_CE
  HANDLE hread,hwrite; CreatePipe(&hread,&hwrite,NULL,0);
  DWORD WINAPI Ex3ThreadFunc(void *dat);
  HANDLE hthread = CreateThread(0,0,Ex3ThreadFunc,(void*)hwrite,0,0);
  ZipAddHandle(hz,_T("simple3.dat"),  hread,1000);  // the '1000' is optional, but it makes for nicer zip files if sizes are known in advance.
  WaitForSingleObject(hthread,INFINITE);
  CloseHandle(hthread); CloseHandle(hread); // the thread will close hwrite
#endif
  //
  // and now that the zip is created in pagefile, let's do something with it:
  void *zbuf; unsigned long zlen; ZipGetMemory(hz,&zbuf,&zlen);
  HANDLE hfz = CreateFile(_T("\\simple3 - pwd is 'password'.zip"),GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
  WriteFile(hfz,zbuf,zlen,&writ,NULL);
  CloseHandle(hfz);
  CloseZip(hz);
  _tprintf(_T("Created 'simple3.zip' via pagefile\n"));


  // EXAMPLE 4 - unzip directly from resource into a file
  // resource RT_RCDATA/#1 happens to be a zip file...
  HINSTANCE hInstance=GetModuleHandle(0);
  HRSRC hrsrc = FindResource(hInstance,MAKEINTRESOURCE(1),RT_RCDATA);
  HANDLE hglob = LoadResource(hInstance,hrsrc);
  void *zipbuf=LockResource(hglob);
  unsigned int ziplen=SizeofResource(hInstance,hrsrc);
  hz = OpenZip(zipbuf, ziplen, 0);  SetUnzipBaseDir(hz,_T("\\"));
  int i; FindZipItem(hz,_T("simple.jpg"),true,&i,&ze);
  //   - unzip to a file -
  UnzipItem(hz,i,ze.name);
  //   - unzip to a membuffer -
  char *ibuf = new char[ze.unc_size];
  UnzipItem(hz,i, ibuf, ze.unc_size);
  delete[] ibuf;
  //   - unzip to a fixed membuff, bit by bit -
  char fbuf[1024]; ZRESULT zr=ZR_MORE; unsigned long totsize=0;
  while (zr==ZR_MORE)
  { zr = UnzipItem(hz,i, fbuf,1024);
    unsigned long bufsize=1024; if (zr==ZR_OK) bufsize=ze.unc_size-totsize;
    // now do something with this chunk which we just unzipped...
    totsize+=bufsize;
  }
  //   - finished -
  CloseZip(hz);
  // note: no need to free resources obtained through Find/Load/LockResource
  _tprintf(_T("Unzipped 'simple.jpg' from resource zipfile\n"));


  
  DeleteFile(_T("\\simple.txt"));
  DeleteFile(_T("\\simple.bmp"));
  _tprintf(_T("Deleted 'simple.txt' and 'simple.bmp'\n"));
}