Beispiel #1
0
bool vic10_expansion_slot_device::call_load()
{
	if (m_card)
	{
		size_t size;

		if (software_entry() == nullptr)
		{
			size = length();

			if (!core_stricmp(filetype(), "80"))
			{
				fread(m_card->m_lorom, 0x2000);

				if (size == 0x4000)
				{
					fread(m_card->m_uprom, 0x2000);
				}
			}
			else if (!core_stricmp(filetype(), "e0"))
			{
				fread(m_card->m_uprom, size);
			}
			else if (!core_stricmp(filetype(), "crt"))
			{
				size_t roml_size = 0;
				size_t romh_size = 0;
				int exrom = 1;
				int game = 1;

				if (cbm_crt_read_header(m_file, &roml_size, &romh_size, &exrom, &game))
				{
					UINT8 *roml = nullptr;
					UINT8 *romh = nullptr;

					m_card->m_lorom.allocate(roml_size);
					m_card->m_uprom.allocate(romh_size);

					if (roml_size) roml = m_card->m_lorom;
					if (romh_size) romh = m_card->m_lorom;

					cbm_crt_read_data(m_file, roml, romh);
				}
			}
		}
		else
		{
			load_software_region("lorom", m_card->m_lorom);
			load_software_region("exram", m_card->m_exram);
			load_software_region("uprom", m_card->m_uprom);
		}
	}

	return IMAGE_INIT_PASS;
}
Beispiel #2
0
bool vic10_expansion_slot_device::call_load()
{
	if (m_cart)
	{
		size_t size = 0;

		if (software_entry() == NULL)
		{
			size = length();

			if (!mame_stricmp(filetype(), "80"))
			{
				fread(m_cart->vic10_lorom_pointer(machine(), 0x2000), 0x2000);

				if (size == 0x4000)
				{
					fread(m_cart->vic10_uprom_pointer(machine(), 0x2000), 0x2000);
				}
			}
			else if (!mame_stricmp(filetype(), "e0")) fread(m_cart->vic10_uprom_pointer(machine(), size), size);
			else if (!mame_stricmp(filetype(), "crt"))
			{
				size_t roml_size = 0;
				size_t romh_size = 0;
				int exrom = 1;
				int game = 1;

				if (cbm_crt_read_header(m_file, &roml_size, &romh_size, &exrom, &game))
				{
					UINT8 *roml = NULL;
					UINT8 *romh = NULL;

					if (roml_size) roml = m_cart->vic10_lorom_pointer(machine(), roml_size);
					if (romh_size) romh = m_cart->vic10_uprom_pointer(machine(), romh_size);

					cbm_crt_read_data(m_file, roml, romh);
				}
			}
		}
		else
		{
			size = get_software_region_length("lorom");
			if (size) memcpy(m_cart->vic10_lorom_pointer(machine(), size), get_software_region("lorom"), size);

			size = get_software_region_length("uprom");
			if (size) memcpy(m_cart->vic10_uprom_pointer(machine(), size), get_software_region("uprom"), size);

			size = get_software_region_length("exram");
			if (size) m_cart->vic10_exram_pointer(machine(), size);
		}
	}

	return IMAGE_INIT_PASS;
}
Beispiel #3
0
/*
 * Displays file status.
 */
int main(int argc, char *const argv[])
{
	struct stat st;
	
	readargs(argc, argv);
	
	/* Get file status. */
	if (stat(filename, &st) < 0)
	{
		printf("stat: cannot stat()\n");
		return (errno);
	}
	
	/* Print file status. */
	printf("    Name: %s\n", filename);
	printf("    Type: %s\n", filetype(st.st_mode));
	printf("    Size: %d bytes\n", (signed)st.st_size);
	printf("   Inode: %u\n", (unsigned)st.st_ino);
	printf("  Device: %xh\n", (unsigned)st.st_dev);
	printf("   Links: %d\n", (signed)st.st_nlink);
	printf("  Access: %s\n",  fileacc(st.st_mode));
	printf(" User ID: %d\n", st.st_uid);
	printf("Group ID: %d\n", st.st_gid);
	
	return (EXIT_SUCCESS);
}
Beispiel #4
0
static int aux_files(lua_State *L)
{
	DIR *d = lua_touserdata(L, lua_upvalueindex(1));
	struct dirent *entry;
	if (d == NULL) luaL_error(L, "attempt to use closed dir");
	entry = readdir(d);
	if (entry == NULL)
	{
		closedir(d);
		lua_pushnil(L);
		lua_replace(L, lua_upvalueindex(1));
		lua_pushnil(L);
	}
	else
	{
		lua_pushstring(L, entry->d_name);
#if 0
#ifdef _DIRENT_HAVE_D_TYPE
		lua_pushstring(L, filetype(DTTOIF(entry->d_type)));
		return 2;
#endif
#endif
	}
	return 1;
}
Beispiel #5
0
void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini) const {
    std::vector<std::string> contentFiles;
    std::string baseGameFile("Game Files:GameFile");
    std::string gameFile("");

    multistrmap::const_iterator it = ini.begin();
    for(int i=0; it != ini.end(); i++) {
        gameFile = baseGameFile;
        gameFile.append(this->numberToString(i));

        it = ini.find(gameFile);
        if(it == ini.end()) {
            break;
        }

        for(std::vector<std::string>::const_iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
            std::string filetype(entry->substr(entry->length()-3));
            Misc::StringUtils::toLower(filetype);

            if(filetype.compare("esm") == 0 || filetype.compare("esp") == 0) {
                contentFiles.push_back(*entry);
            }
        }

        gameFile = "";
    }

    cfg.erase("content");
    cfg.insert( std::make_pair("content", std::vector<std::string>() ) );

    for(std::vector<std::string>::const_iterator it=contentFiles.begin(); it!=contentFiles.end(); ++it) {
        cfg["content"].push_back(*it);
    }
}
Beispiel #6
0
int main(int argc, char *argv[]) {
  struct stat st;

  if (argc != 2) {
    fprintf(stderr, "%s: wrong arguments\n", argv[0]);
    exit(1);
  }

  if (lstat(argv[1], &st) < 0) {
    perror(argv[1]);
    exit(1);
  }

  printf("type\t%o (%s)\n", (st.st_mode & S_IFMT), filetype(st.st_mode));
  printf("mode\t%o\n", st.st_mode & ~S_IFMT);
  printf("dev\t%llu\n", (unsigned long long)st.st_dev);
  printf("ino\t%lu\n", (unsigned long)st.st_ino);
  printf("rdev\t%llu\n", (unsigned long long)st.st_rdev);
  printf("nlink\t%d\n", st.st_nlink);
  printf("uid\t%d\n", st.st_uid);
  printf("gid\t%d\n", st.st_gid);
  printf("size\t%lld\n", st.st_size);
  printf("blksize\t%lu\n", (unsigned long)st.st_blksize);
  printf("blocks\t%lu\n", (unsigned long)st.st_blocks);
  printf("atime\t%s", ctime(&st.st_atime));
  printf("mtime\t%s", ctime(&st.st_mtime));
  printf("ctime\t%s", ctime(&st.st_ctime));

  exit(0);
}
Beispiel #7
0
int main(int argc, char *argv[])
{
	if (argc != 2)
	{
		fprintf(stderr, "Usage %s file\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	struct stat sbuf;
	printf("Filename:%s\n", argv[1]);
	if (lstat(argv[1], &sbuf) == -1)
		ERR_EXIT("stat error");

	printf("File number:major %d,minor %d inode %d\n", MAJOR(sbuf.st_dev), MINOR(sbuf.st_dev), (int)sbuf.st_ino);
	if (filetype(&sbuf))
	{
		printf("Device number:major %d,minor %d\n", MAJOR(sbuf.st_rdev), MINOR(sbuf.st_rdev));
	}
	
	char perm[11] = {0};
	fileperm(&sbuf, perm);
	printf("File permission bits=%o %s\n", sbuf.st_mode & 07777, perm);
	

	return 0;
}
Beispiel #8
0
/*
 * Print sorted down columns
 */
static void
print_by_column(Char *dir, Char *items[], int count)
{
    int i, rows, r, c, maxwidth = 0, columns;

    if (ioctl(SHOUT, TIOCGWINSZ, (ioctl_t) & win) < 0 || win.ws_col == 0)
	win.ws_col = 80;
    for (i = 0; i < count; i++)
	maxwidth = maxwidth > (r = Strlen(items[i])) ? maxwidth : r;
    maxwidth += 2;		/* for the file tag and space */
    columns = win.ws_col / maxwidth;
    if (columns == 0)
	columns = 1;
    rows = (count + (columns - 1)) / columns;
    for (r = 0; r < rows; r++) {
	for (c = 0; c < columns; c++) {
	    i = c * rows + r;
	    if (i < count) {
		int w;

		(void) fprintf(cshout, "%s", vis_str(items[i]));
		(void) fputc(dir ? filetype(dir, items[i]) : ' ', cshout);
		if (c < columns - 1) {	/* last column? */
		    w = Strlen(items[i]) + 1;
		    for (; w < maxwidth; w++)
			(void) fputc(' ', cshout);
		}
	    }
	}
	(void) fputc('\r', cshout);
	(void) fputc('\n', cshout);
    }
}
int main(int argc,char **argv)
{
	if(argc!=2)
	{
		printf("Usage:%s file \n",argv[0]);
		exit(EXIT_FAILURE);
	}

	struct stat statbuf;
	printf("file name:%s \n",argv[1]);
	if(lstat(argv[1],&statbuf)<0)
	  ERR_EXIT("stat");
	printf("主设备号(块号):%d,次设备号:%d\n",MAJOR(statbuf.st_dev),MINOR(statbuf.st_dev));
	printf("i节点号:%d\n",(int)statbuf.st_ino);
	printf("硬链接数:%d\n",(int)statbuf.st_nlink);
	printf("用户名:%s,(%d)\n",getuname(&statbuf),(int)statbuf.st_uid);
	printf("组名:%s,(%d)\n",getgname(&statbuf),(int)statbuf.st_gid);
	printf("磁盘id:%d\n",(int)statbuf.st_rdev);
	printf("文件大小:%d\n",(int)statbuf.st_size);
	filetype(&statbuf);
	printf("文件的权限:%o  ",statbuf.st_mode & 00777);
	char permission[11]="----------";
	filepermission(&statbuf,permission);
	printf("%s\n",permission);
	return 0;
}
std::shared_ptr<Sound_Engine::Sound> Sound_Engine::LoadSound(std::string file){
	std::string::size_type po = file.find_last_of('\\');
	if(po == std::string::npos) po = file.find_last_of('/');// couldnt find it with the double slashes, try a single forward slash
	if(po == std::string::npos) {// no slashes.. there must be no path on this string so append our asset directory to where the sounds are stored
		file = Internal::Asset_Dir + "Sound\\" + file;
	}// else the user specified some sort of directory, so use that instead.
		
	std::ifstream f(file.c_str(), std::ios::beg | std::ios::binary);
	assert(f);
	// see if the sound data has been loaded already
	std::map<std::string, std::weak_ptr<Internal::Sub_Sound>>::iterator soundloaded = Internal::LoadedSounds.find(file);
	if(soundloaded != Internal::LoadedSounds.end()) {// the data exists
		std::shared_ptr<Internal::Sub_Sound> ptr(soundloaded->second.lock());
		if(ptr){// the sound data still exists
			std::shared_ptr<Sound_Engine::Sound> sound_ptr = std::make_shared<Sound_Engine::Sound>();// create a new source 
			sound_ptr->InternalSound = ptr;
			Internal::Sources[sound_ptr.get()] = sound_ptr;// insert into the sources
			return sound_ptr;
		}
	}
	std::shared_ptr<Sound_Engine::Sound> retsound = std::make_shared<Sound_Engine::Sound>();
	Internal::Sources[retsound.get()] = retsound;
	retsound->InternalSound = std::make_shared<Internal::Sub_Sound>();
	Internal::LoadedSounds[file]=retsound->InternalSound;

	retsound->InternalSound->buffer.Flags = XAUDIO2_END_OF_STREAM; // tell the source voice not to expect any data after this buffer

	DWORD dwChunkSize(0);
	DWORD dwChunkPosition(0);
	//check the file type, should be fourccWAVE or 'XWMA'
	FindChunk(f,fourccRIFF,dwChunkSize, dwChunkPosition );
	DWORD filetype(0);
	ReadChunkData(f, &filetype, sizeof(DWORD), dwChunkPosition);
	if (filetype != fourccWAVE){
		if(filetype != fourccXWMA){
			f.close();
			OUTPUT_DEBUG_MSG("File is not a .wav, or a xwma file... uh oh");
			assert(true);
		}
	}
	FindChunk(f,fourccFMT, dwChunkSize, dwChunkPosition );
	ReadChunkData(f, &retsound->InternalSound->wfx, dwChunkSize, dwChunkPosition );
	FindChunk(f,fourccDATA,dwChunkSize, dwChunkPosition );
	retsound->InternalSound->buffer.AudioBytes = dwChunkSize;  //buffer containing audio data
	BYTE *temp = new BYTE[dwChunkSize];  //size of the audio buffer in bytes
	retsound->InternalSound->buffer.pAudioData = temp;
	ReadChunkData(f, temp, dwChunkSize, dwChunkPosition);
	if(filetype == fourccXWMA){// the file is an xwma file... we need an extra peice of data
		FindChunk(f,fourccDPDS, dwChunkSize, dwChunkPosition );
		// the chunksize is how many bytess there are, so we have to divide by sizeof(uint32t) to get the number of uint32's in the buffer
		//so chunksize will be like 24, but that is how many bytes, we need 24/4 which is 6. Because there are 6 uint32's
		retsound->InternalSound->wmaBuffer.PacketCount = dwChunkSize / sizeof(UINT32); 
		UINT32 *temp2 = new UINT32[retsound->InternalSound->wmaBuffer.PacketCount];
		ReadChunkData(f, temp2, dwChunkSize, dwChunkPosition);
		retsound->InternalSound->wmaBuffer.pDecodedPacketCumulativeBytes= temp2;
	}
	f.close();
	return retsound;
}
Beispiel #11
0
void snapshot_image_device::timer_callback()
{
	/* invoke the load */
	(*m_load)(*this, filetype(), length());

	/* unload the device */
	unload();
}
Beispiel #12
0
bool vic20_expansion_slot_device::call_load()
{
	if (m_cart)
	{
		size_t size = 0;

		if (software_entry() == NULL)
		{
			if (!mame_stricmp(filetype(), "20")) fread(m_cart->vic20_blk1_pointer(machine(), 0x2000), 0x2000);
			else if (!mame_stricmp(filetype(), "40")) fread(m_cart->vic20_blk2_pointer(machine(), 0x2000), 0x2000);
			else if (!mame_stricmp(filetype(), "60")) fread(m_cart->vic20_blk3_pointer(machine(), 0x2000), 0x2000);
			else if (!mame_stricmp(filetype(), "70")) fread(m_cart->vic20_blk3_pointer(machine(), 0x2000) + 0x1000, 0x1000);
			else if (!mame_stricmp(filetype(), "a0")) fread(m_cart->vic20_blk5_pointer(machine(), 0x2000), 0x2000);
			else if (!mame_stricmp(filetype(), "b0")) fread(m_cart->vic20_blk5_pointer(machine(), 0x2000) + 0x1000, 0x1000);
			else if (!mame_stricmp(filetype(), "crt"))
			{
				// read the header
				UINT8 header[2];
				fread(&header, 2);
				UINT16 address = pick_integer_le(header, 0, 2);

				if (LOG) logerror("Address %04x\n", address);

				switch (address)
				{
				case 0x2000: fread(m_cart->vic20_blk1_pointer(machine(), 0x2000), 0x2000); break;
				case 0x4000: fread(m_cart->vic20_blk2_pointer(machine(), 0x2000), 0x2000); break;
				case 0x6000: fread(m_cart->vic20_blk3_pointer(machine(), 0x2000), 0x2000); break;
				case 0x7000: fread(m_cart->vic20_blk3_pointer(machine(), 0x2000) + 0x1000, 0x1000); break;
				case 0xa000: fread(m_cart->vic20_blk5_pointer(machine(), 0x2000), 0x2000); break;
				case 0xb000: fread(m_cart->vic20_blk5_pointer(machine(), 0x2000) + 0x1000, 0x1000); break;
				default: return IMAGE_INIT_FAIL;
				}
			}
		}
		else
		{
			size = get_software_region_length("blk1");
			if (size) memcpy(m_cart->vic20_blk1_pointer(machine(), size), get_software_region("blk1"), size);

			size = get_software_region_length("blk2");
			if (size) memcpy(m_cart->vic20_blk2_pointer(machine(), size), get_software_region("blk2"), size);

			size = get_software_region_length("blk3");
			if (size) memcpy(m_cart->vic20_blk3_pointer(machine(), size), get_software_region("blk3"), size);

			size = get_software_region_length("blk5");
			if (size) memcpy(m_cart->vic20_blk5_pointer(machine(), size), get_software_region("blk5"), size);

			size = get_software_region_length("ram");
			if (size) memcpy(m_cart->vic20_ram_pointer(machine(), size), get_software_region("ram"), size);

			size = get_software_region_length("nvram");
			if (size) memcpy(m_cart->vic20_nvram_pointer(machine(), size), get_software_region("nvram"), size);

		}
	}

	return IMAGE_INIT_PASS;
}
/* Buffer Function to arrange function parameters*/
int passarray(char* path,http_response_t *response,http_request_t *request,int newfd)
{
	time_date(response);
	filetype(request,response);
	filesize(&path,response,request);
	build_response(request, response);
	send_response(response,&path,newfd);
	return 0;
}
Beispiel #14
0
static int Pstat(lua_State *L)			/** stat(path,[selector]) */
{
	struct mystat s;
	const char *path=luaL_checkstring(L, 1);
	if (lstat(path,&s.s)==-1) return pusherror(L, path);
	s.type=filetype(s.s.st_mode);
	modechopper(s.s.st_mode, s.mode);
	return doselection(L, 2, Sstat, Fstat, &s);
}
Beispiel #15
0
bool cbm2_expansion_slot_device::call_load()
{
	size_t size = 0;

	if (m_card)
	{
		if (software_entry() == NULL)
		{
			size = length();

			if (!mame_stricmp(filetype(), "20"))
			{
				fread(m_card->cbm2_bank1_pointer(machine(), size), size);
			}
			else if (!mame_stricmp(filetype(), "40"))
			{
				fread(m_card->cbm2_bank2_pointer(machine(), size), size);
			}
			else if (!mame_stricmp(filetype(), "60"))
			{
				fread(m_card->cbm2_bank3_pointer(machine(), size), size);
			}
		}
		else
		{
			size = get_software_region_length("bank1");
			if (size) memcpy(m_card->cbm2_bank1_pointer(machine(), size), get_software_region("bank1"), size);

			size = get_software_region_length("bank2");
			if (size) memcpy(m_card->cbm2_bank2_pointer(machine(), size), get_software_region("bank2"), size);

			size = get_software_region_length("bank3");
			if (size) memcpy(m_card->cbm2_bank3_pointer(machine(), size), get_software_region("bank3"), size);

			size = get_software_region_length("ram");
			if (size) memset(m_card->cbm2_ram_pointer(machine(), size), 0, size);

			size = get_software_region_length("nvram");
			if (size) memset(m_card->cbm2_nvram_pointer(machine(), size), 0, size);
		}
	}

	return IMAGE_INIT_PASS;
}
Beispiel #16
0
/*
 * Uncompress a file and return the new file name, if the file doesn't
 * appear to be compressed or the uncompression fails, the original
 * file name will be returned.  In all cases, the return value is
 * allocated with XtNewString().
 *
 * We use "system()" in here to avoid the hassle of converting the
 * decompression commands from strings to argv's but this means that
 * some kludging is needed to grab the error output.  This would be
 * "cleaner" (in some sense) if pipe/dup2/fork/exec/XtAppAddInput
 * were used instead but sometimes laziness is good.
 */
char *
mgv_unmangle(MGV *m, char *file)
{
#	define  CMD_FMT "%s <%s >%s 2>%s"
	char    *cmd, *out, *tmp, *s;
	int     t, cmd_size;
	MGV_APP *r = mgv_appres(m->main);

	if((t = filetype(file)) == FT_NORM
	|| (tempdir == NULL && !mk_tmp(r->temp_dir)))
		return XtNewString(file);

	if((s = strrchr(file, '/')) == NULL)
		s = file;
	else
		++s;

	out = XtCalloc(strlen(tempdir) + 1 + strlen(s) + 1 + 64 + 1, 1);
	tmp = XtCalloc(strlen(tempdir) + 1 + 64 + 1 + 1, 1);

	sprintf(out, "%s/%s.%ld.%d", tempdir, s,
				(long)XtWindow(m->main), m->inst_num);
	sprintf(tmp, "%s/%ld.%d", tempdir, (long)getpid(), m->inst_num);

	cmd_size = strlen(file) + strlen(out) + strlen(tmp) + sizeof(CMD_FMT);

	switch(t) {
	case FT_GZIP:
		cmd = XtCalloc(cmd_size + strlen(r->gunzip), 1);
		sprintf(cmd, "%s <%s >%s 2>%s", r->gunzip, file, out, tmp);
		break;
	case FT_BZIP:
		cmd = XtCalloc(cmd_size + strlen(r->bunzip), 1);
		sprintf(cmd, "%s <%s >%s 2>%s", r->bunzip, file, out, tmp);
		break;
	default:
		assert("mgv_unmangle(): confused by file type!" != NULL);
		XtFree(out);
		XtFree(tmp);
		return XtNewString(file);
		break;
	}

	errno = 0;
	if(system(cmd) != 0 && errno != 0) {
		XtFree(out);
		out = XtNewString(file);
	}
	showmsg(m, file, &tmp[0]);

	XtFree(tmp);
	XtFree(cmd);

	return out;
#	undef CMD_FMT
}
Beispiel #17
0
static void catcb(char *dir, char *file,struct stat *stdat,void *ext) {
  FILE *fp = (FILE *)ext;
  fprintf(fp, "%d %s %03o n:%d u:%d g:%d s:%llu b:%d ts:%d %s%s%s\n",
	  (int)stdat->st_ino, filetype(stdat->st_mode),
	  stdat->st_mode & ~S_IFMT,
	  (int)stdat->st_nlink, stdat->st_uid, stdat->st_gid,
	  (unsigned long long)stdat->st_size, (int)stdat->st_blocks,
	  (int)stdat->st_mtime,
	  dir, dir[0] ? "/" : "", file);
}
Beispiel #18
0
static int
stat_f(
	int		argc,
	char		**argv)
{
	struct dioattr	dio;
	struct fsxattr	fsx, fsxa;
	struct stat64	st;
	int		verbose = (argc == 2 && !strcmp(argv[1], "-v"));

	printf(_("fd.path = \"%s\"\n"), file->name);
	printf(_("fd.flags = %s,%s,%s%s%s%s%s\n"),
		file->flags & IO_OSYNC ? _("sync") : _("non-sync"),
		file->flags & IO_DIRECT ? _("direct") : _("non-direct"),
		file->flags & IO_READONLY ? _("read-only") : _("read-write"),
		file->flags & IO_REALTIME ? _(",real-time") : "",
		file->flags & IO_APPEND ? _(",append-only") : "",
		file->flags & IO_NONBLOCK ? _(",non-block") : "",
		file->flags & IO_TMPFILE ? _(",tmpfile") : "");
	if (fstat64(file->fd, &st) < 0) {
		perror("fstat64");
	} else {
		printf(_("stat.ino = %lld\n"), (long long)st.st_ino);
		printf(_("stat.type = %s\n"), filetype(st.st_mode));
		printf(_("stat.size = %lld\n"), (long long)st.st_size);
		printf(_("stat.blocks = %lld\n"), (long long)st.st_blocks);
		if (verbose) {
			printf(_("stat.atime = %s"), ctime(&st.st_atime));
			printf(_("stat.mtime = %s"), ctime(&st.st_mtime));
			printf(_("stat.ctime = %s"), ctime(&st.st_ctime));
		}
	}
	if (file->flags & IO_FOREIGN)
		return 0;
	if ((xfsctl(file->name, file->fd, XFS_IOC_FSGETXATTR, &fsx)) < 0 ||
	    (xfsctl(file->name, file->fd, XFS_IOC_FSGETXATTRA, &fsxa)) < 0) {
		perror("XFS_IOC_FSGETXATTR");
	} else {
		printf(_("fsxattr.xflags = 0x%x "), fsx.fsx_xflags);
		printxattr(fsx.fsx_xflags, verbose, 0, file->name, 1, 1);
		printf(_("fsxattr.projid = %u\n"), fsx.fsx_projid);
		printf(_("fsxattr.extsize = %u\n"), fsx.fsx_extsize);
		printf(_("fsxattr.nextents = %u\n"), fsx.fsx_nextents);
		printf(_("fsxattr.naextents = %u\n"), fsxa.fsx_nextents);
	}
	if ((xfsctl(file->name, file->fd, XFS_IOC_DIOINFO, &dio)) < 0) {
		perror("XFS_IOC_DIOINFO");
	} else {
		printf(_("dioattr.mem = 0x%x\n"), dio.d_mem);
		printf(_("dioattr.miniosz = %u\n"), dio.d_miniosz);
		printf(_("dioattr.maxiosz = %u\n"), dio.d_maxiosz);
	}
	return 0;
}
Beispiel #19
0
std::string vic10_expansion_slot_device::get_default_card_software()
{
	if (open_image_file(mconfig().options()))
	{
		if (!core_stricmp(filetype(), "crt"))
			return cbm_crt_get_card(m_file);

		clear();
	}

	return software_get_default_slot("standard");
}
Beispiel #20
0
const char * c64_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
{
	if (open_image_file(options))
	{
		if (!mame_stricmp(filetype(), "crt"))
		{
			return cbm_crt_get_card(m_file);
		}

		clear();
	}

	return software_get_default_slot(config, options, this, "standard");
}
Beispiel #21
0
static PyObject *
stat_filemode(PyObject *self, PyObject *omode)
{
    char buf[10];
    mode_t mode;

    mode = _PyLong_AsMode_t(omode);
    if ((mode == (mode_t)-1) && PyErr_Occurred())
        return NULL;

    buf[0] = filetype(mode);
    fileperm(mode, &buf[1]);
    return PyUnicode_FromStringAndSize(buf, 10);
}
Beispiel #22
0
int main(int argc, char * * argv)
{
    ftype_t in_type, out_type;
    int in_index, out_index;
    long bytes = -1; //optional, <0=copy entire file
    int i;
    
    if (argc < 4)
    {
        printf("Usage: %s -i <infile> -o <outfile> [optional args]\n"
               "-i\tInput file\n"
               "-o\tOutput file\n"
               "-c\tNumber of bytes to copy\n", argv[0]);
        for (i = 1; i < argc; i++)
        {
            if (strcmp(argv[i], "-i") == 0)
            {
                in_index = i + 1;
                i++;
            }
            if (strcmp(argv[i], "-o") == 0)
            {
                out_index = i + 1;
                i++;
            }
            if (strcmp(argv[i], "-c") == 0)
            {
                bytes = atol(argv[i + 1]);
                i++;
            }
        }
    }
    out_type = filetype(argv[out_index]);
    in_type = filetype(argv[in_index]);
    printf("Input\tType: %x\tSize: %llub\n", in_type, getsize(argv[in_index], in_type));
    printf("Outut\tType: %x\tSize: %llub\n", out_type, getsize(argv[out_index], out_type));
}
Beispiel #23
0
void c64_expansion_slot_device::get_default_card_software(astring &result)
{
	if (open_image_file(mconfig().options()))
	{
		if (!mame_stricmp(filetype(), "crt"))
		{
			cbm_crt_get_card(result, m_file);
			return;
		}

		clear();
	}

	software_get_default_slot(result, "standard");
}
Beispiel #24
0
bool cbm2_expansion_slot_device::call_load()
{
	size_t size = 0;

	if (m_card)
	{
		if (software_entry() == NULL)
		{
			size = length();

			if (!core_stricmp(filetype(), "20"))
			{
				m_card->m_bank1.allocate(size);
				fread(m_card->m_bank1, size);
			}
			else if (!core_stricmp(filetype(), "40"))
			{
				m_card->m_bank2.allocate(size);
				fread(m_card->m_bank2, size);
			}
			else if (!core_stricmp(filetype(), "60"))
			{
				m_card->m_bank3.allocate(size);
				fread(m_card->m_bank3, size);
			}
		}
		else
		{
			load_software_region("bank1", m_card->m_bank1);
			load_software_region("bank2", m_card->m_bank2);
			load_software_region("bank3", m_card->m_bank3);
		}
	}

	return IMAGE_INIT_PASS;
}
Beispiel #25
0
static bool macho_dump_32(char *img, size_t size, lambchop_logger *logger) {
  char *ptr = img;
  struct mach_header *hdr;

  hdr = (struct mach_header*)ptr;
  ptr += sizeof(struct mach_header);

  lambchop_debug(logger, "cputype = %s\n", cputype(hdr->cputype));
  lambchop_debug(logger, "cpusubtype = 0x%x\n", hdr->cpusubtype);
  lambchop_debug(logger, "filetype = %s\n", filetype(hdr->filetype));
  lambchop_debug(logger, "ncmds = %d\n", hdr->ncmds);
  lambchop_debug(logger, "sizeofcmds = %d\n", hdr->sizeofcmds);
  lambchop_debug(logger, "flags = 0x%x\n", hdr->flags);

  return macho_dump(img, hdr->ncmds, ptr, true, logger);
}
Beispiel #26
0
image_init_result legacy_floppy_image_device::internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args)
{
	floperr_t err;
	const struct FloppyFormat *floppy_options;
	int floppy_flags, i;

	device_image_interface *image = nullptr;
	interface(image);   /* figure out the floppy options */
	floppy_options = m_config->formats;

	if (is_create)
	{
		/* creating an image */
		assert(create_format >= 0);
		err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &m_floppy);
		if (err)
			goto error;
	}
	else
	{
		/* opening an image */
		floppy_flags = !is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY;
		err = floppy_open_choices((void *) image, &image_ioprocs, filetype(), floppy_options, floppy_flags, &m_floppy);
		if (err)
			goto error;
	}
	if (floppy_callbacks(m_floppy)->get_heads_per_disk && floppy_callbacks(m_floppy)->get_tracks_per_disk)
	{
		floppy_drive_set_geometry_absolute(floppy_get_tracks_per_disk(m_floppy),floppy_get_heads_per_disk(m_floppy));
	}
	/* disk changed */
	m_dskchg = CLEAR_LINE;

	// If we have one of our hacky load procs, call it
	if (m_load_proc)
		m_load_proc(*this, is_create);

	return image_init_result::PASS;

error:
	for (i = 0; i < ARRAY_LENGTH(errmap); i++)
	{
		if (err == errmap[i].ferr)
			seterror(errmap[i].ierr, errmap[i].message);
	}
	return image_init_result::FAIL;
}
Beispiel #27
0
void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) {
    std::vector<std::string> esmFiles;
    std::vector<std::string> espFiles;
    std::string baseGameFile("Game Files:GameFile");
    std::string gameFile("");

    multistrmap::iterator it = ini.begin();
    for(int i=0; it != ini.end(); i++) {
        gameFile = baseGameFile;
        gameFile.append(this->numberToString(i));

        it = ini.find(gameFile);
        if(it == ini.end()) {
            break;
        }

        for(std::vector<std::string>::iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
            std::string filetype(entry->substr(entry->length()-4, 3));
            std::transform(filetype.begin(), filetype.end(), filetype.begin(), ::tolower);

            if(filetype.compare("esm") == 0) {
                esmFiles.push_back(*entry);
            }
            else if(filetype.compare("esp") == 0) {
                espFiles.push_back(*entry);
            }
        }

        gameFile = "";
    }

    cfg.erase("master");
    cfg.insert( std::make_pair<std::string, std::vector<std::string> > ("master", std::vector<std::string>() ) );

    for(std::vector<std::string>::iterator it=esmFiles.begin(); it!=esmFiles.end(); ++it) {
        cfg["master"].push_back(*it);
    }

    cfg.erase("plugin");
    cfg.insert( std::make_pair<std::string, std::vector<std::string> > ("plugin", std::vector<std::string>() ) );

    for(std::vector<std::string>::iterator it=espFiles.begin(); it!=espFiles.end(); ++it) {
        cfg["plugin"].push_back(*it);
    }
}
Beispiel #28
0
int legacy_floppy_image_device::internal_floppy_device_load(int create_format, util::option_resolution *create_args)
{
	floperr_t err;
	const struct FloppyFormat *floppy_options;
	int floppy_flags, i;
	const char *extension;

	device_image_interface *image = nullptr;
	interface(image);   /* figure out the floppy options */
	floppy_options = m_config->formats;

	if (has_been_created())
	{
		/* creating an image */
		assert(create_format >= 0);
		err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &m_floppy);
		if (err)
			goto error;
	}
	else
	{
		/* opening an image */
		floppy_flags = !is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY;
		extension = filetype();
		err = floppy_open_choices((void *) image, &image_ioprocs, extension, floppy_options, floppy_flags, &m_floppy);
		if (err)
			goto error;
	}
	if (floppy_callbacks(m_floppy)->get_heads_per_disk && floppy_callbacks(m_floppy)->get_tracks_per_disk)
	{
		floppy_drive_set_geometry_absolute(floppy_get_tracks_per_disk(m_floppy),floppy_get_heads_per_disk(m_floppy));
	}
	/* disk changed */
	m_dskchg = CLEAR_LINE;

	return IMAGE_INIT_PASS;

error:
	for (i = 0; i < ARRAY_LENGTH(errmap); i++)
	{
		if (err == errmap[i].ferr)
			seterror(errmap[i].ierr, errmap[i].message);
	}
	return IMAGE_INIT_FAIL;
}
Beispiel #29
0
void lsdir(char *d, char *b) {
  struct dir_entry *e;
  char fn[19]; // Includes null & quotes
  fn[0]= '"';
  while (b) {
    for (int i=0; i<BLK_SIZE; i+=sizeof(*e)) {
      e = (struct dir_entry*)(&b[i]);
      if (e->type) {
        int size = e->file_size_low + 256*e->file_size_high;
        trim(&fn[1], e->filename, sizeof(fn)-2);
        strcat(fn, "\"");
        printf("%-4d %-18s %s%s (%d,%d) [%d bytes]\n",
            size, fn, filetype(e->type), filebits(e->type), e->track, e->sector,
            file_size(d, e->track, e->sector));
      }
    }
    b = nextblock(d, b);
  }
}
Beispiel #30
0
main()
{
	register int i, j = getdtablesize();
	struct stat sb;
	char *filetype();

	for (i = 0; i < j; i++) {
		if (fstat(i, &sb) < 0)
			continue;
		fprintf(stderr, "%d: %s, inode #%d, mode %o, dev (%d,%d)",
		    i, filetype(sb.st_mode & S_IFMT), sb.st_ino,
		    sb.st_mode &~ S_IFMT,
		    major(sb.st_dev), minor(sb.st_dev));
		if ((sb.st_mode & S_IFMT) == S_IFCHR ||
		    (sb.st_mode & S_IFMT) == S_IFBLK)
			fprintf(stderr, ", rdev (%d, %d)",
			    major(sb.st_rdev), minor(sb.st_rdev));
		putc('\n', stderr);
	}
	exit(0);
}