int main() { int N = 50; int PenDrive = 4000; int *Arquivos = (int*)malloc(sizeof(int) * N); GenerateFiles(Arquivos, N, 300); int *Arq = Sort(Arquivos,N); printf("Total espeaço: %i\n", PenDrive); printa(Arq, N); int soma = 0, i=0; soma = Sum(Arq,N); printf("Total Arquivos (MB): %i \n",soma); for(i=0;i<N ;i++) if(PenDrive >= Arq[i]){ printf("+ %i MB\n", Arq[i]); PenDrive -= Arq[i]; Arq[i] = 0; } printf("Sobrou (MB): %i \n",PenDrive); soma= Sum(Arq,N); printf("Sobrou %i MB nos Arquivos!\n",soma); return 0; }
int main(int argc, char** argv) { if (argc < 3) { Usage(argv[0]); exit(-1); } try { std::pair<std::string, std::string> fileNames = GenerateFiles(argv[2]); int c = 0; Configuration::Instance().LoadConfiguration(argv[1]); Logger::Instance().Init(fileNames.first); Logger::Instance().AddNecessaryMessage(Configuration::Instance().GetDump()); Logger::Instance().AddNecessaryMessage((std::string("\n\nSetup Description:\n---------------------\n ") + argv[3] + "\n\n").c_str()); EventHandlerAcquisition eventHandler(fileNames.second); DigitizerManager digitizerManager(eventHandler); digitizerManager.InitAndConfigure(); digitizerManager.Start(); int i = 0; while ( true) { try { digitizerManager.Acquire(); } catch (ExceptionBase& ex) { printf("%s\n", ex.What().c_str()); Logger::Instance().AddNecessaryMessage(ex.What() + "\n"); sleep(1); } c = checkCommand(); if (c == 1) break; } std::cout << "Press 'q' again to quit..."<< std::endl; fflush(stdout); do { c = checkCommand(); eventHandler.ProcessEvents(); }while (c != 1); } catch(ExceptionBase& ex) { std::cout << "CAUGHT EXCEPTION. Details:\t" << ex.What() << std::endl << "Exiting..." << std::endl; return -1; } return 0; }
already_AddRefed<FileList> DataTransferItemList::Files( nsIPrincipal* aPrincipal) { // The DataTransfer can hold data with varying principals, coming from // different windows. This means that permissions checks need to be made when // accessing data from the DataTransfer. With the accessor methods, this is // checked by DataTransferItem::Data(), however with files, we keep a cached // live copy of the files list for spec compliance. // // A DataTransfer is only exposed to one webpage, and chrome code. The chrome // code should be able to see all files on the DataTransfer, while the webpage // should only be able to see the files it can see. As chrome code doesn't // need as strict spec compliance as web visible code, we generate a new // FileList object every time you access the Files list from chrome code, but // re-use the cached one when accessing from non-chrome code. // // It is not legal to expose an identical DataTransfer object is to multiple // different principals without using the `Clone` method or similar to copy it // first. If that happens, this method will assert, and return nullptr in // release builds. If this functionality is required in the future, a more // advanced caching mechanism for the FileList objects will be required. RefPtr<FileList> files; if (nsContentUtils::IsSystemPrincipal(aPrincipal)) { files = new FileList(mDataTransfer); GenerateFiles(files, aPrincipal); return files.forget(); } if (!mFiles) { mFiles = new FileList(mDataTransfer); mFilesPrincipal = aPrincipal; RegenerateFiles(); } if (!aPrincipal->Subsumes(mFilesPrincipal)) { MOZ_ASSERT(false, "This DataTransfer should only be accessed by the system " "and a single principal"); return nullptr; } files = mFiles; return files.forget(); }
void GenerateFilesJob::Run() { GenerateFiles(m_numFiles, m_fileSize, m_basePath); }
///--------------------------------------------------------------------------------- /// ///--------------------------------------------------------------------------------- void GenerateFilesJob::Run() { GenerateFiles( m_numFiles, m_fileSize ); }