void ExtractScummMac::execute() {
	Common::Filename inPath(_inputPaths[0].path);
	Common::Filename outPath(_outputPath);

	if (outPath.empty())
		outPath.setFullPath("./");

	Common::File ifp(inPath, "rb");

	// Get the length of the data file to use for consistency checks
	uint32 dataFileLength = ifp.size();

	// Read offset and length to the file records
	uint32 fileRecordOffset = ifp.readUint32BE();
	uint32 fileRecordLength = ifp.readUint32BE();

	// Do a quick check to make sure the offset and length are good
	if (fileRecordOffset + fileRecordLength > dataFileLength)
		error("File records out of bounds");

	// Do a little consistancy check on fileRecordLength
	if (fileRecordLength % 0x28)
		error("File record length not multiple of 40");

	// Extract the files
	for (uint32 i = 0; i < fileRecordLength; i += 0x28) {
		// read a file record
		ifp.seek(fileRecordOffset + i, SEEK_SET);

		uint32 fileOffset = ifp.readUint32BE();
		uint32 fileLength = ifp.readUint32BE();

		char fileName[0x21];
		ifp.read_throwsOnError(fileName, 0x20);
		fileName[0x20] = 0;

		if (!fileName[0])
			error("File has no name");

		print("Extracting %s...", fileName);

		// Consistency check. make sure the file data is in the file
		if (fileOffset + fileLength > dataFileLength)
			error("File out of bounds");

		// Write a file
		ifp.seek(fileOffset, SEEK_SET);

		outPath.setFullName(fileName);
		Common::File ofp(outPath, "wb");

		byte *buf = new byte[fileLength];
		ifp.read_throwsOnError(buf, fileLength);
		ofp.write(buf, fileLength);
		delete[] buf;
	}
}
Exemplo n.º 2
0
/***********************************************************
 * DeleteFiles: Delete tmp files
 ***********************************************************/
void
PGP::DeleteFiles()
{
	BPath inPath(fTmpDirPath.Path());
	inPath.Append(INPUT_FILENAME);
	BPath outPath(fTmpDirPath.Path());
	outPath.Append(OUTPUT_FILENAME);
	
	BString cmd;
	cmd = "rm -rf ";
	cmd += inPath.Path(); 
	cmd += " ";
	cmd += outPath.Path();
	::system(cmd.String());
}
Exemplo n.º 3
0
	bool exportFile(const char* inFile, const char* outFile)
	{
		try
		{
			std::filesystem::path inPath(inFile);
			std::filesystem::path outPath(outFile);

			if (std::filesystem::is_directory(outPath) == true &&
				inPath.has_filename() == true)
			{
				outPath /= inPath.filename();
			}

			auto data = readChar(inFile);
			auto newFile = std::fstream(outPath, std::ios::out | std::ios::binary);
			newFile.write((char*)&data[0], data.size());
			newFile.close();
		}
		catch (std::exception&) {}
		return false;
	}
Exemplo n.º 4
0
/**
* adds a new embryo to the list of embryos
* procs: list of embryos
* info: information about current execution context of embryos_init
* name: name of this embryo
**/
_BOOL embryo_create(EMBRYO *procs,EMBRYO_INFO *info, char *name){
  if(info->cur_proc+1 >= MAX_JOBS ){
    errno = ENOMEM;
    return FALSE;
  }

  EMBRYO * new_proc = &procs[++info->cur_proc]; //retrieve a new proc entry
  new_proc->fork_seq = info->fork_seq; //set the fork sequence

  //starts forming the job name
  //first entry in the job
  //forkseqname is the pre-cursor to jobname
  if(info->cur_proc-1 <0 || procs[info->cur_proc-1].fork_seq != new_proc->fork_seq){
    if(strlen(name)+1 > MAX_JOB_NAME){
      errno = ENOMEM;
      return FALSE;
    }
    strcpy(info->forkseqname[info->fork_seq-1],name);
  }
  //this is not the first entry in the job
  else{
    if(strlen(name)+strlen(info->forkseqname[info->fork_seq-1])+2 > MAX_JOB_NAME){
      errno = ENOMEM;
      return FALSE;
    }
    strcat(info->forkseqname[info->fork_seq-1]," ");
    strcat(info->forkseqname[info->fork_seq-1],name);

  }


  //attempt to get the process name and check if it is in the path if necessary
  if(strlen(name)+1>PATH_LIM){
    info->cur_proc-=1;
    errno = ENOMEM;
    return FALSE;
  }
  short key = NONE;
  new_proc->internal_key = NONE;
  if(((strstr(name,"/")!= NULL) ? strcpy(new_proc->program,name) :( (key=inInternal(name)) && inPath(name,new_proc->program,PATH_LIM))? new_proc->program : NULL)  ==NULL){
    //it might be a command internal to the shell
    if(key!=NONE){
      new_proc->internal_key = key;
    }
    else{
        info->cur_proc-=1;
        errno = ENOENT;
        return FALSE;
    }
  }
  //set up args
  new_proc->num_args = 0;
  //set up file-descriptors
  new_proc->p_pipe_read = -1;
  new_proc->p_stdin = -1;
  new_proc->p_stdout = -1;
  return TRUE;

}
Exemplo n.º 5
0
void MSP3D::reducedGraph(){
	m_graph.clear();
	m_nodes.clear();
	m_start_index=-1;
	m_end_index=-1;
	octomap::OcTree::tree_iterator it_end=m_tree.end_tree();
	bool skip=false;
	int depth=0;
	for(octomap::OcTree::tree_iterator it=m_tree.begin_tree();it!=it_end;++it){
		if(skip){
			if(it.getDepth()<=depth){
				skip=false;
			}
		}
		if(!skip){
			if((it.getCoordinate()-m_current_coord).norm()>m_alpha*it.getSize()  || it.isLeaf()){
				if(!inPath(it.getCoordinate(),it.getSize())){
					m_nodes.push_back(std::pair<octomap::point3d,double>(it.getCoordinate(),it.getSize()));
				}
				skip=true;
				depth=it.getDepth();
			}
		}
	}
	int l=m_nodes.size();

//	std::cout<< "number of nodes: " << l << std::endl;
	for(int i=0;i<l;++i){
		// !!!!!!!!!!!!!  if not in path?
//		std::cout<< "node " << i << ":" << m_nodes[i].first <<std::endl;
		m_graph.add_vertex(i);
		if(is_start(m_nodes[i])){
//			std::cout<<"start: "<< m_nodes[i].first <<std::endl;
			if(m_start_index!=-1){
				std::cout << "2 start nodes, fail" << std::endl;
				exit(1);
			}
			m_start_index=i;
		}
		if(is_goal(m_nodes[i])){
//			std::cout<<"end: "<< m_nodes[i].first <<std::endl;
			if(m_end_index!=-1){
				std::cout << "2 end nodes, fail" << std::endl;
				exit(1);
			}
			m_end_index=i;
		}
	}
	if(m_start_index==-1){
		std::cout << "0 start node, fail" << std::endl;
	}
	if(m_end_index==-1){
		std::cout << "0 end node, fail" << std::endl;
	}
	for(int i=0;i<l;++i){
		for(int j=i+1;j<l;++j){
				if(neighboor(m_nodes[i],m_nodes[j])){
//					std::cout<< "neighboor:" << i << "," << j <<std::endl;
//					std::cout<< "cost:" << cost(i,j) <<std::endl;
					m_graph.add_edge(i,j,cost(i,j));
					m_graph.add_edge(j,i,cost(j,i));
				}
		}
	}
}