Exemplo n.º 1
0
/*
 * Changes the working directory of the process
 *
 * req: TLV_TYPE_DIRECTORY_PATH - The directory path to change the working
 *                                directory to.
 */
DWORD request_fs_chdir(Remote * remote, Packet * packet)
{
	Packet *response = packet_create_response(packet);
	char *directory;
	DWORD result;
	directory = packet_get_tlv_value_string(packet, TLV_TYPE_DIRECTORY_PATH);

	if (directory == NULL) {
		result = ERROR_INVALID_PARAMETER;
	} else {
		result = fs_chdir(directory);
	}

	packet_add_tlv_uint(response, TLV_TYPE_RESULT, result);
	return PACKET_TRANSMIT(remote, response, NULL);
}
Exemplo n.º 2
0
void DC_LoadMaps() {
    DC_CheckForMaps("/cd");
    DC_CLS();

    fs_chdir(dcwolf3dpath);

#ifdef SPEAR
#ifndef SPEARDEMO
    fs_copy("audiohed.sod", "/ram/audiohed.sod");
    fs_copy("audiot.sod", "/ram/audiot.sod");
    fs_copy("vgadict.sod", "/ram/vgadict.sod");
    fs_copy("vgagraph.sod", "/ram/vgagraph.sod");
    fs_copy("vgahead.sod", "/ram/vgahead.sod");
    switch(param_mission) {
        case 0:
            fs_copy("gamemaps.sod", "/ram/gamemaps.sod");
            fs_copy("maphead.sod", "/ram/maphead.sod");
            fs_copy("vswap.sod", "/ram/vswap.sod");
            break;
        case 1:
            fs_copy("gamemaps.sd1", "/ram/gamemaps.sd1");
            fs_copy("maphead.sd1", "/ram/maphead.sd1");
            fs_copy("vswap.sd1", "/ram/vswap.sd1");
            break;
        case 2:
            fs_copy("gamemaps.sd2", "/ram/gamemaps.sd2");
            fs_copy("maphead.sd2", "/ram/maphead.sd2");
            fs_copy("vswap.sd2", "/ram/vswap.sd2");
            break;
        case 3:
            fs_copy("gamemaps.sd3", "/ram/gamemaps.sd3");
            fs_copy("maphead.sd3", "/ram/maphead.sd3");
            fs_copy("vswap.sd3", "/ram/vswap.sd3");
            break;
    }
#else
    fs_copy("audiohed.sdm", "/ram/audiohed.sdm");
    fs_copy("audiot.sdm", "/ram/audiot.sdm");
    fs_copy("vgadict.sdm", "/ram/vgadict.sdm");
    fs_copy("vgagraph.sdm", "/ram/vgagraph.sdm");
    fs_copy("vgahead.sdm", "/ram/vgahead.sdm");
    fs_copy("gamemaps.sdm", "/ram/gamemaps.sdm");
    fs_copy("maphead.sdm", "/ram/maphead.sdm");
    fs_copy("vswap.sdm", "/ram/vswap.sdm");
#endif
#else
#ifndef UPLOAD
    fs_copy("audiohed.wl6", "/ram/audiohed.wl6");
    fs_copy("audiot.wl6", "/ram/audiot.wl6");
    fs_copy("vgadict.wl6", "/ram/vgadict.wl6");
    fs_copy("vgagraph.wl6", "/ram/vgagraph.wl6");
    fs_copy("vgahead.wl6", "/ram/vgahead.wl6");
    fs_copy("gamemaps.wl6", "/ram/gamemaps.wl6");
    fs_copy("maphead.wl6", "/ram/maphead.wl6");
    fs_copy("vswap.wl6", "/ram/vswap.wl6");
#else
    fs_copy("audiohed.wl1", "/ram/audiohed.wl1");
    fs_copy("audiot.wl1", "/ram/audiot.wl1");
    fs_copy("vgadict.wl1", "/ram/vgadict.wl1");
    fs_copy("vgagraph.wl1", "/ram/vgagraph.wl1");
    fs_copy("vgahead.wl1", "/ram/vgahead.wl1");
    fs_copy("gamemaps.wl1", "/ram/gamemaps.wl1");
    fs_copy("maphead.wl1", "/ram/maphead.wl1");
    fs_copy("vswap.wl1", "/ram/vswap.wl1");
#endif
#endif

    fs_chdir("/ram");
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
	DetectMemoryLeaks();

	printf("AngelScript version: %s\n", asGetLibraryVersion());
	printf("AngelScript options: %s\n", asGetLibraryOptions());

#ifdef __dreamcast__
	fs_chdir(asTestDir);
#endif

	InstallMemoryManager();

	if( TestScriptRetRef::Test()       ) goto failed; else printf("-- TestScriptRetRef passed\n");
	if( TestGarbageCollect::Test()     ) goto failed; else printf("-- TestGarbageCollect passed\n");
	if( TestFunctionPtr::Test()        ) goto failed; else printf("-- TestFunctionPtr passed\n");
	if( TestModule::Test()             ) goto failed; else printf("-- TestModule passed\n");
	if( TestGetSet::Test()             ) goto failed; else printf("-- TestGetSet passed\n");
	if( Test_Addon_ScriptArray::Test() ) goto failed; else printf("-- Test_Addon_ScriptArray passed\n");
	if( TestOperator::Test()           ) goto failed; else printf("-- TestOperator passed\n");
	if( TestTemplate::Test()           ) goto failed; else printf("-- TestTemplate passed\n");
	if( TestDump::Test()               ) goto failed; else printf("-- TestDump passed\n");
	if( TestInheritance::Test()        ) goto failed; else printf("-- TestInheritance passed\n");
	if( TestScriptClassMethod::Test()  ) goto failed; else printf("-- TestScriptClassMethod passed\n");
	if( TestScriptString::Test()       ) goto failed; else printf("-- TestScriptString passed\n");
	if( TestSaveLoad::Test()           ) goto failed; else printf("-- TestSaveLoad passed\n");
	if( TestInterface::Test()          ) goto failed; else printf("-- TestInterface passed\n");
	if( TestCastOp::Test()             ) goto failed; else printf("-- TestCastOp passed\n");
	if( Test2Modules()                 ) goto failed; else printf("-- Test2Modules passed\n");
	if( TestFile::Test()               ) goto failed; else printf("-- TestFile passed\n");
	if( TestArrayObject::Test()        ) goto failed; else printf("-- TestArrayObject passed\n");
	if( TestCompiler::Test()           ) goto failed; else printf("-- TestCompiler passed\n");
	if( TestOptimize()                 ) goto failed; else printf("-- TestOptimize passed\n");
	if( TestConversion::Test()         ) goto failed; else printf("-- TestConversion passed\n");
	if( TestRegisterType::Test()       ) goto failed; else printf("-- TestRegisterType passed\n");
	if( TestRefArgument::Test()        ) goto failed; else printf("-- TestRefArgument passed\n");
	if( TestStream::Test()             ) goto failed; else printf("-- TestStream passed\n");
	if( TestEnum::Test()               ) goto failed; else printf("-- TestEnum passed\n");
	if( TestDynamicConfig::Test()      ) goto failed; else printf("-- TestDynamicConfig passed\n");
	if( TestObjHandle::Test()          ) goto failed; else printf("-- TestObjHandle passed\n");
	if( TestGlobalVar()                ) goto failed; else printf("-- TestGlobalVar passed\n");
	if( TestScriptStruct::Test()       ) goto failed; else printf("-- TestScriptStruct passed\n");
	if( TestRZ::Test()                 ) goto failed; else printf("-- TestRZ passed\n");
	if( TestArray::Test()              ) goto failed; else printf("-- TestArray passed\n");
	if( TestAny::Test()                ) goto failed; else printf("-- TestAny passed\n");
	if( TestObjHandle2::Test()         ) goto failed; else printf("-- TestObjHandle2 passed\n");
	if( TestMetaData::Test()           ) goto failed; else printf("-- TestMetaData passed\n");
	if( TestDictionary::Test()         ) goto failed; else printf("-- TestDictionary passed\n");
	if( TestVector3()                  ) goto failed; else printf("-- TestVector3 passed\n");
	if( TestConstObject::Test()        ) goto failed; else printf("-- TestConstObject passed\n");
	if( TestImplicitCast::Test()       ) goto failed; else printf("-- TestImplicitCast passed\n");
	if( TestImplicitHandle::Test()     ) goto failed; else printf("-- TestImplicitHandle passed\n");
	if( TestFor::Test()                ) goto failed; else printf("-- TestFor passed\n");
	if( TestRefCast::Test()            ) goto failed; else printf("-- TestRefCast passed\n");
	if( TestStdString()                ) goto failed; else printf("-- TestStdString passed\n");
	if( TestStack2::Test()             ) goto failed; else printf("-- TestStack2 passed\n");
	if( TestStdVector::Test()          ) goto failed; else printf("-- TestStdVector passed\n");
	if( TestArrayHandle::Test()        ) goto failed; else printf("-- TestArrayHandle passed\n");
	if( TestDict::Test()               ) goto failed; else printf("-- TestDict passed\n");
	if( TestMultiAssign::Test()        ) goto failed; else printf("-- TestMultiAssign passed\n");
	if( TestException()                ) goto failed; else printf("-- TestException passed\n");
	if( TestInt8::Test()               ) goto failed; else printf("-- TestInt8 passed\n");
	if( TestGeneric::Test()            ) goto failed; else printf("-- TestGeneric passed\n");
	if( TestBStr()                     ) goto failed; else printf("-- TestBStr passed\n");
	if( TestTypedef::Test()            ) goto failed; else printf("-- TestTypedef passed\n");
	if( TestImport::Test()             ) goto failed; else printf("-- TestImport passed\n");
	if( TestAssign::Test()             ) goto failed; else printf("-- TestAssign passed\n");
	if( TestSwitch()                   ) goto failed; else printf("-- TestSwitch passed\n");
	if( TestExceptionMemory::Test()    ) goto failed; else printf("-- TestExceptionMemory passed\n");
	if( TestObject::Test()             ) goto failed; else printf("-- TestObject passed\n");
	if( TestFactory::Test()            ) goto failed; else printf("-- TestFactory passed\n");
	if( TestFuncOverload()             ) goto failed; else printf("-- TestFuncOverload passed\n");
	if( TestObjZeroSize::Test()        ) goto failed; else printf("-- TestObjZeroSize passed\n");
	if( TestSingleton::Test()          ) goto failed; else printf("-- TestSingleton passed\n");
	if( TestCondition()                ) goto failed; else printf("-- TestCondition passed\n");
	if( TestObject2::Test()            ) goto failed; else printf("-- TestObject2 passed\n");
	if( TestShark::Test()              ) goto failed; else printf("-- TestShark passed\n");
	if( TestBool::Test()               ) goto failed; else printf("-- TestBool passed\n");
	if( TestBits::Test()               ) goto failed; else printf("-- TestBits passed\n");
	if( TestDestructor::Test()         ) goto failed; else printf("-- TestDestructor passed\n");
	if( TestConstructor2::Test()       ) goto failed; else printf("-- TestConstructor2 passed\n");
	if( TestUnsafeRef::Test()          ) goto failed; else printf("-- TestUnsafeRef passed\n");
	if( TestVarType::Test()            ) goto failed; else printf("-- TestVarType passed\n");
	if( TestScriptMath::Test()         ) goto failed; else printf("-- TestScriptMath passed\n");
	if( TestDebug::Test()              ) goto failed; else printf("-- TestDebug passed\n");
	if( TestGetArgPtr::Test()          ) goto failed; else printf("-- TestGetArgPtr passed\n");
	if( TestAutoHandle::Test()         ) goto failed; else printf("-- TestAutoHandle passed\n");
	if( TestObject3::Test()            ) goto failed; else printf("-- TestObject3 passed\n");
	if( TestArrayIntf::Test()          ) goto failed; else printf("-- TestArrayIntf passed\n");
	if( TestConstProperty::Test()      ) goto failed; else printf("-- TestConstProperty passed\n");
	if( TestSuspend::Test()            ) goto failed; else printf("-- TestSuspend passed\n");
	if( TestVector3_2::Test()          ) goto failed; else printf("-- TestVector3_2 passed\n");
	if( TestNested()                   ) goto failed; else printf("-- TestNested passed\n");
	if( TestConstructor()              ) goto failed; else printf("-- TestConstructor passed\n");
	if( TestExecuteScript()            ) goto failed; else printf("-- TestExecuteScript passed\n");
	if( TestCustomMem::Test()          ) goto failed; else printf("-- TestCustomMem passed\n");
	if( TestPostProcess::Test()        ) goto failed; else printf("-- TestPostProcess passed\n");
	if( TestArgRef::Test()             ) goto failed; else printf("-- TestArgRef passed\n");
	if( TestNotInitialized()           ) goto failed; else printf("-- TestNotInitialized passed\n");
	if( TestConfig::Test()             ) goto failed; else printf("-- TestConfig passed\n");
	if( TestInt64()                    ) goto failed; else printf("-- TestInt64 passed\n");
	if( TestImport2::Test()            ) goto failed; else printf("-- TestImport2 passed\n");
	if( TestEnumGlobVar()              ) goto failed; else printf("-- TestEnumGlobVar passed\n");
	if( TestConfigAccess::Test()       ) goto failed; else printf("-- TestConfigAccess passed\n");
	if( TestDiscard::Test()            ) goto failed; else printf("-- TestDiscard passed\n");
	if( TestParser::Test()             ) goto failed; else printf("-- TestParser passed\n");
	if( TestFloat::Test()              ) goto failed; else printf("-- TestFloat passed\n");
	if( TestTempVar()                  ) goto failed; else printf("-- TestTempVar passed\n");
	if( TestModuleRef()                ) goto failed; else printf("-- TestModuleRef passed\n");
	if( TestExecuteString()            ) goto failed; else printf("-- TestExecuteString passed\n");
	if( TestStack()                    ) goto failed; else printf("-- TestStack passed\n");
	if( TestCreateEngine()             ) goto failed; else printf("-- TestCreateEngine passed\n");
	if( TestLongToken()                ) goto failed; else printf("-- TestLongToken passed\n");
	if( TestOutput::Test()             ) goto failed; else printf("-- TestOutput passed\n");
	if( Test2Func::Test()              ) goto failed; else printf("-- Test2Func passed\n");
	if( TestCircularImport::Test()     ) goto failed; else printf("-- TestCircularImport passed\n");
	if( TestNeverVisited()             ) goto failed; else printf("-- TestNeverVisited passed\n");

	// The following tests are designed specifically to test the native calling conventions.
	// These are grouped by calling convention and ordered in increasing complexity.
	{
		// cdecl
		if( TestExecute()                 ) goto failed; else printf("-- TestExecute passed\n");
		if( TestCDeclReturn::Test()       ) goto failed; else printf("-- TestCDeclReturn passed\n");
		if( TestExecute1Arg()             ) goto failed; else printf("-- TestExecute1Arg passed\n");
		if( TestExecute2Args()            ) goto failed; else printf("-- TestExecute2Args passed\n");
		if( TestExecute4Args()            ) goto failed; else printf("-- TestExecute4Args passed\n");
		if( TestExecute4Argsf()           ) goto failed; else printf("-- TestExecute4Argsf passed\n");
		if( TestExecuteMixedArgs()        ) goto failed; else printf("-- TestExecuteMixedArgs passed\n");
		if( TestExecute32Args()           ) goto failed; else printf("-- TestExecute32Args passed\n");
		if( TestExecute32MixedArgs()      ) goto failed; else printf("-- TestExecute32MixedArgs passed\n");
		if( TestCDecl_Class()             ) goto failed; else printf("-- TestCDecl_Class passed\n");
		if( TestCDecl_ClassA()            ) goto failed; else printf("-- TestCDecl_ClassA passed\n");
		if( TestCDecl_ClassC()            ) goto failed; else printf("-- TestCDecl_ClassC passed\n");
		if( TestCDecl_ClassD()            ) goto failed; else printf("-- TestCDecl_ClassD passed\n");

		// cdecl_objlast and cdecl_objfirst
		if( TestReturnString::Test()      ) goto failed; else printf("-- TestReturnString passed\n");
		if( TestNegateOperator()          ) goto failed; else printf("-- TestNegateOperator passed\n");
		if( TestReturnWithCDeclObjFirst() ) goto failed; else printf("-- TestReturnWithCDeclObjFirst passed\n");

		// thiscall
		if( TestExecuteThis32MixedArgs()  ) goto failed; else printf("-- TestExecuteThis32MixedArgs passed\n");
		if( TestNotComplexThisCall()      ) goto failed; else printf("-- TestNotComplexThisCall passed\n");
		if( TestVirtualMethod()           ) goto failed; else printf("-- TestVirtualMethod passed\n");
		if( TestMultipleInheritance()     ) goto failed; else printf("-- TestMultipleInheritance passed\n");
		if( TestVirtualInheritance()      ) goto failed; else printf("-- TestVirtualInheritance passed\n");

		// stdcall
		if( TestStdcall4Args()            ) goto failed; else printf("-- TestStdcall4Args passed\n");
		if( TestNotComplexStdcall()       ) goto failed; else printf("-- TestNotComplexStdcall passed\n");
	}

	// This test uses ATL::CString thus it is turned off by default
//	if( TestCString::Test()           ) goto failed; else printf("-- TestCString passed\n");
	// Pointers are not supported by AngelScript at the moment, but they may be in the future
//	if( TestPointer::Test()           ) goto failed; else printf("-- TestPointer passed\n");

	RemoveMemoryManager();

//succeed:
	printf("--------------------------------------------\n");
	printf("All of the tests passed with success.\n\n");
#if !defined(DONT_WAIT) && (defined(WIN32) || defined(_WIN64))
	printf("Press any key to quit.\n");
	while(!_getch());
#endif
	return 0;

failed:
	printf("--------------------------------------------\n");
	printf("One of the tests failed, see details above.\n\n");
#if !defined(DONT_WAIT) && (defined(WIN32) || defined(_WIN64))
	printf("Press any key to quit.\n");
	while(!_getch());
#endif
	return -1;
}
Exemplo n.º 4
0
void init_text(int splash)
{
	SDL_Surface *tmp;

	if (prSDLScreen==NULL)
	{
		SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK);
		prSDLScreen=SDL_SetVideoMode(320,240,16,VIDEO_FLAGS);
    		SDL_ShowCursor(SDL_DISABLE);
 	   	//SDL_JoystickEventState(SDL_ENABLE);
    		//SDL_JoystickOpen(0);
	}
#ifdef DREAMCAST
        __sdl_dc_emulate_keyboard=1;
#endif
	if (!text_screen)
	{
		text_screen=SDL_CreateRGBSurface(prSDLScreen->flags,prSDLScreen->w,prSDLScreen->h,prSDLScreen->format->BitsPerPixel,prSDLScreen->format->Rmask,prSDLScreen->format->Gmask,prSDLScreen->format->Bmask,prSDLScreen->format->Amask);
		tmp=SDL_LoadBMP(MENU_FILE_TEXT);
		if (text_screen==NULL || tmp==NULL)
			exit(-1);
		text_image=SDL_DisplayFormat(tmp);
		SDL_FreeSurface(tmp);
		if (text_image==NULL)
			exit(-2);
		SDL_SetColorKey(text_image,(SDL_SRCCOLORKEY | SDL_RLEACCEL),SDL_MapRGB(text_image -> format, 0, 0, 0));
		tmp=SDL_LoadBMP(MENU_FILE_BACKGROUND);
		if (tmp==NULL)
			exit(-3);
		text_background=SDL_DisplayFormat(tmp);
		SDL_FreeSurface(tmp);
		if (text_background==NULL)
			exit(-3);
		tmp=SDL_LoadBMP(MENU_FILE_WINDOW);
		if (tmp==NULL)
			exit(-4);
		text_window_background=SDL_DisplayFormat(tmp);
		SDL_FreeSurface(tmp);
		if (text_window_background==NULL)
			exit(-5);
	}
	if (splash)
	{
		SDL_Surface *sur;
		SDL_Rect r;
		int i,j;

		obten_colores();
		uae4all_init_sound();
		if (skipintro) goto skipintro;
#if !defined(DEBUG_UAE4ALL) && !defined(PROFILER_UAE4ALL) && !defined(AUTO_RUN) && !defined(AUTO_FRAMERATE)
		tmp=SDL_LoadBMP(MENU_FILE_SPLASH);
		if (tmp==NULL)
			exit(-6);
		sur = SDL_DisplayFormat(tmp);
		SDL_FreeSurface(tmp);
		r.x=(text_screen->w - sur->w)/2;
		r.y=(text_screen->h - sur->h)/2;
		r.h=sur->w;
		r.w=sur->h;
		SDL_FillRect(text_screen,NULL,0xFFFFFFFF);
		for (i=128;i>-8;i-=8)
		{
#ifdef DREAMCAST
			vid_waitvbl();
#else
			SDL_Delay(50);
#endif
			SDL_FillRect(text_screen,NULL,0xFFFFFFFF);
			SDL_BlitSurface(sur,NULL,text_screen,&r);
			fade16(text_screen,i);
			text_flip();
		}
		SDL_Delay(3000);
		for(i=0;i<128;i+=16)
		{
#ifdef DREAMCAST
			vid_waitvbl();
#else
			SDL_Delay(50);
#endif
			SDL_FillRect(text_screen,NULL,0xFFFFFFFF);
			SDL_BlitSurface(sur,NULL,text_screen,&r);
			fade16(text_screen,i);
			text_flip();
		}
		for(i=128;i>-8;i-=8)
		{
#ifdef DREAMCAST
			vid_waitvbl();
#else
			SDL_Delay(50);
#endif
			text_draw_background();
			fade16(text_screen,i);
			text_flip();
		}
		SDL_FreeSurface(sur);
#else
#if !defined (DREAMCAST) && !defined (GP2X)
		chdir("example");
#else
#ifdef DREAMCAST
		fs_chdir("/cd");
#endif
#endif
#endif
skipintro:
		for(i=0;i<10;i++)
		{
			SDL_Event ev;
			if (!uae4all_init_rom(romfile))
				break;

			text_draw_background();
			text_draw_window(54,91,250,64,"--- ERROR ---");
			write_text(11,14,"KICK.ROM not found");
			write_text(8,16,"Press any button to retry");
			text_flip();
			SDL_Delay(333);
			while(SDL_PollEvent(&ev))
#ifndef DREAMCAST
				if (ev.type==SDL_QUIT)
					exit(1);
				else
#endif
				SDL_Delay(10);
			while(!SDL_PollEvent(&ev))
				SDL_Delay(10);
			while(SDL_PollEvent(&ev))
				if (ev.type==SDL_QUIT)
					exit(1);
			text_draw_background();
			text_flip();
			SDL_Delay(333);
		}
		if (i>=10)
			exit(1);
	}
	else
	{
		SDL_FillRect(text_screen,NULL,0xFFFFFFFF);
		text_flip();
		uae4all_resume_music();
	}
	menu_msg_time=SDL_GetTicks();
}
Exemplo n.º 5
0
int process_request(const char *line, FILE *fp, FileSystem *fs) {
    char command[4096];
    
#ifdef DEBUG
    fprintf(stderr, "process request `%s`\n", line);
#endif
    sscanf(line, "%s", command);
#ifdef DEBUG
    fprintf(stderr, "command is `%s`\n", command);
#endif
    if (0 == strcmp("f", command)) {
        fs_format(fs);
        return RESULT_DONE;
    } else if (0 == strcmp("mk", command)) {
        char f[4096];
        char parent_path[4096];
        
        sscanf(line + 2, "%s", f);
#ifdef DEBUG
        fprintf(stderr, "> mk `%s`\n", f);
#endif
        if (fs_exists(fs, f)) {
#ifdef DEBUG
            fprintf(stderr, "> `%s` already exists\n", f);
#endif
            return RESULT_NO;
        } else {
#ifdef DEBUG
            fprintf(stderr, "> going to create `%s`\n", f);
#endif
        }
        fs_split_path(f, parent_path, NULL);
        if (fs_isdir(fs, parent_path)) {
            if (fs_create(fs, f)) {
#ifdef DEBUG
                fprintf(stderr, "> failed to create `%s`\n", f);
#endif
                return RESULT_NO;
            }
            return RESULT_YES;
        }
#ifdef DEBUG
        fprintf(stderr, "> parent path `%s` is not a directory\n", parent_path);
#endif
        return RESULT_NO;
    } else if (0 == strcmp("mkdir", command)) {
        char d[4096];
        char parent_path[4096];
        
        sscanf(line + 5, "%s", d);
        if (fs_exists(fs, d)) {
            return RESULT_NO;
        }
        fs_split_path(d, parent_path, NULL);
        if (fs_isdir(fs, parent_path)) {
            if (fs_mkdir(fs, d)) {
                return RESULT_NO;
            }
            return RESULT_YES;
        }
        return RESULT_NO;
    } else if (0 == strcmp("rm", command)) {
        char f[4096];
        
        sscanf(line + 2, "%s", f);
        if (fs_isfile(fs, f)) {
            if (fs_unlink(fs, f)) {
                return RESULT_NO;
            }
            return RESULT_YES;
        }
        return RESULT_NO;
    } else if (0 == strcmp("cd", command)) {
        char path[4096];
        
        sscanf(line + 2, "%s", path);
        if (fs_isdir(fs, path)) {
            if (fs_chdir(fs, path)) {
                return RESULT_NO;
            }
            return RESULT_YES;
        }
#ifdef DEBUG
        fprintf(stderr, "`%s` is not a directory\n", path);
#endif
        return RESULT_NO;
    } else if (0 == strcmp("rmdir", command)) {
        char d[4096];
        
        sscanf(line + 5, "%s", d);
        if (fs_isdir(fs, d)) {
            if (fs_rmdir(fs, d)) {
                return RESULT_NO;
            }
            return RESULT_YES;
        }
        return RESULT_NO;
    } else if (0 == strcmp("ls", command)) {
        fs_ls(fs, fp);
        return RESULT_ELSE;
    } else if (0 == strcmp("cat", command)) {
        char f[4096];
        
        sscanf(line + 3, "%s", f);
        if (fs_isfile(fs, f)) {
            fs_cat(fs, f, fp);
            return RESULT_ELSE;
        }
        return RESULT_NO;
    } else if (0 == strcmp("w", command)) {
        char f[4096];
        int l;
        char data[4096];
        
        sscanf(line + 1, "%s %d %[^\n]", f, &l, data);
        if (fs_isfile(fs, f)) {
            if (fs_write(fs, f, l, data)) {
                return RESULT_NO;
            }
            return RESULT_YES;
        }
        return RESULT_NO;
    } else if (0 == strcmp("i", command)) {
        char f[4096];
        int pos;
        int l;
        char data[4096];
        
        sscanf(line + 1, "%s %d %d %[^\n]", f, &pos, &l, data);
        if (fs_isfile(fs, f)) {
            if (fs_insert(fs, f, pos, l, data)) {
                return RESULT_NO;
            }
            return RESULT_YES;
        }
        return RESULT_NO;
    } else if (0 == strcmp("d", command)) {
        char f[4096];
        int pos;
        int l;
        
        sscanf(line + 1, "%s %d %d", f, &pos, &l);
        if (fs_isfile(fs, f)) {
            if (fs_delete(fs, f, pos, l)) {
                return RESULT_NO;
            }
            return RESULT_YES;
        }
        return RESULT_NO;
    } else if (0 == strcmp("e", command)) {
        return RESULT_EXIT;
    }
    return RESULT_ELSE;
}
Exemplo n.º 6
0
void msg_chdir(message_t msg)
{
	msg->w1 = fs_chdir(msg->tid, msg->snd_ptr);
	reply_message(msg->tid, msg);
}
Exemplo n.º 7
0
int fs_OpenDir(fs_char *fs_path, fs_romfs_char *path, u32 pathlen, fs_dir *dir)
{
	//printf("init open dir\n");
	int ret = 0;
	fs_DIR *dp;
	fs_entry *entry;
	
	//printf("check if path exists\n");
	dp = fs_opendir(fs_path);
	if(!dp)
	{
		//wprintf(L"[!] Failed to open directory: \"%s\"\n",path);
		return -1;
	}
	
	//printf("do some more init\n");
	fs_InitDir(path,pathlen,dir);
	//wprintf(L" rec: \"%s\" (%d)\n",dir->name,dir->name_len);
	
	//printf("chdir\n");
	fs_chdir(fs_path);
	
	//printf("read entries\n");
	while((entry = fs_GetEntry(dp)))
	{
		if(!entry)
		{
			ret = -1;
			break;
		}
		
		if(entry->IsDir)
		{		
			//printf("Found Dir ");
			if(!fs_EntryIsDirNav(entry))
			{
#ifdef _WIN32
			//wprintf(L"is a dir: \"%s\" (%d)\n",entry->fs_name,entry->name_len);
#else
			//printf("is a dir: \"%s\" (%d)\n",entry->fs_name,entry->name_len);
#endif
				ret = fs_AddDir(entry,dir);
			}
			else
			{
				//printf("Not wanted dir\n");
				ret = 0;
			}
		}
		else
		{
#ifdef _WIN32
			//wprintf(L"is a file: \"%s\" (%d)\n",entry->fs_name,entry->name_len);
#else
			//printf("is a file: \"%s\" (%d)\n",entry->fs_name,entry->name_len);
#endif
			ret = fs_AddFile(entry,dir);
		}
		
		//printf("free entry\n");		
		fs_FreeEntry(entry);
		
		if(ret)
		{
			//printf("error parsing entry\n");
			break;
		}
	}
	//printf("close dir ptr\n");
	fs_closedir(dp);
	//printf("return up dir\n");
	fs_chdirUp();
	//printf("return from fs_OpenDir();\n");
	return ret;
}
Exemplo n.º 8
0
int gdfiles(char *dst_folder,char *dst_file,char *text){
	file_t gdfd;
	FILE *gdifd;
	
	CDROM_TOC gdtoc;
	CDROM_TOC cdtoc;
	int track ,lba ,gdtype ,cdtype;
	uint8 *buff = memalign(32, 32768);
	
	cdrom_set_sector_size (2048);
	if(cdrom_read_toc(&cdtoc, 0) != CMD_OK) { 
		ds_printf("DS_ERROR:CD Toc read error\n"); 
		free(buff); 
		return CMD_ERROR; 
	}
	
	if(cdrom_read_toc(&gdtoc, 1) != CMD_OK) { 
		ds_printf("DS_ERROR:GD Toc read error\n"); 
		free(buff); 
		return CMD_ERROR; 
	}
	
	if(cdrom_read_sectors(buff,45150,16)) { 
		ds_printf("DS_ERROR: IP.BIN read error\n"); 
		free(buff); 
		return CMD_ERROR; 
	}
	
	strcpy(dst_file,"\0"); 
	snprintf(dst_file,MAX_FN_LEN,"%s/IP.BIN",dst_folder); 
	
	if ((gdfd=fs_open(dst_file,O_WRONLY | O_TRUNC | O_CREAT)) == FILEHND_INVALID) { 
		ds_printf("DS_ERROR: Error open IP.BIN for write\n"); 
		free(buff); 
		return CMD_ERROR; 
	}
	
	if (fs_write(gdfd,buff,32768) == -1) {
		ds_printf("DS_ERROR: Error write IP.BIN\n"); 
		free(buff); 
		fs_close(gdfd); 
		return CMD_ERROR;
	}
	
	fs_close(gdfd); 
	free(buff);
	ds_printf("IP.BIN succes dumped\n");
	
	fs_chdir(dst_folder);
	strcpy(dst_file,"\0"); 
	snprintf(dst_file,MAX_FN_LEN,"%s.gdi",text);
	if ((gdifd=fopen(dst_file,"w")) == NULL){
		ds_printf("DS_ERROR: Error open %s.gdi for write\n",text); 
		return CMD_ERROR; 
	}
	
	int cdfirst = TOC_TRACK(cdtoc.first);
	int cdlast = TOC_TRACK(cdtoc.last);
	int gdfirst = TOC_TRACK(gdtoc.first);
	int gdlast = TOC_TRACK(gdtoc.last);
	fprintf(gdifd,"%d\n",gdlast);
	
	for (track=cdfirst; track <= cdlast; track++ ) {
		lba = TOC_LBA(cdtoc.entry[track-1]);
		lba -= 150;
		cdtype = TOC_CTRL(cdtoc.entry[track-1]);
		fprintf(gdifd, "%d %d %d %d track%02d.%s 0\n",track,lba,cdtype,(cdtype == 4 ? 2048 : 2352),track,(cdtype == 4 ? "iso" : "raw"));
	}
	
	for (track=gdfirst; track <= gdlast; track++ ) {
		lba = TOC_LBA(gdtoc.entry[track-1]);
		lba -= 150;
		gdtype = TOC_CTRL(gdtoc.entry[track-1]);
		fprintf(gdifd, "%d %d %d %d track%02d.%s 0\n",track,lba,gdtype,(gdtype == 4 ? 2048 : 2352),track,(gdtype == 4 ? "iso" : "raw"));
	}
	
	fclose(gdifd); 
	fs_chdir("/");
	ds_printf("%s.gdi succes writen\n",text);

return CMD_OK;	
}
Exemplo n.º 9
0
void init_text(int splash)
{
	SDL_Event ev;
	int toexit=0;
	SDL_Surface *sur;
	SDL_Rect r;
	int i,j;


	if (!text_screen)
	{

//		text_screen=SDL_ConvertSurface(screen,screen->format,0);
		text_screen=SDL_CreateRGBSurface(screen->flags,screen->w,screen->h,screen->format->BitsPerPixel,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,screen->format->Amask);
//		text_screen=SDL_DisplayFormat(screen);
		if (!text_screen)
		{
#ifdef STDOUTPUT
			puts("Unable to make a SDL_Surface (text_screen)");
#endif
			exit(-1);

		}
	}

#ifdef DREAMCAST
        __sdl_dc_emulate_keyboard=1;
#endif
	if (!splash)
	{
		menu_raise();
		return;
	}

	text_image2=load_img_0(MENU_FILE_TEXT2);
	font_inv.Surface=text_image2;
	SFont_InitFontInfo(&font_inv);

	text_image=load_img_0(MENU_FILE_TEXT);
	SFont_InitFont(text_image);

	text_win_uleft=load_img_255(MENU_FILE_WIN_ULEFT);
	text_win_uright=load_img_255(MENU_FILE_WIN_URIGHT);
	text_win_upper=load_img_255(MENU_FILE_WIN_UPPER);
	text_win_left=load_img_255(MENU_FILE_WIN_LEFT);
	text_win_right=load_img_255(MENU_FILE_WIN_RIGHT);
	text_win_bright=load_img_255(MENU_FILE_WIN_BRIGHT);
	text_win_bleft=load_img_255(MENU_FILE_WIN_BLEFT);
	text_win_bottom=load_img_255(MENU_FILE_WIN_BOTTOM);
	text_cdrom=menu_IMG_Load(MENU_FILE_LOADING);

	init_background();

	obten_colores();
	sound_play_menu_music();
#ifndef AUTO_EVENTS
	sur=menu_IMG_Load(MENU_FILE_SPLASH);
	r.x=(text_screen->w - sur->w)/2;
	r.y=(text_screen->h - sur->h)/2;
	r.h=sur->w;
	r.w=sur->h;
	SDL_FillRect(text_screen,NULL,0); //0xFFFFFFFF);
	while(SDL_PollEvent(&ev)) SDL_Delay(50);
	for (i=128;(i>-8)&&(!toexit);i-=8)
	{
#ifdef DREAMCAST
		vid_waitvbl();
#else
		SDL_Delay(50);
#endif
		SDL_FillRect(text_screen,NULL,0); //0xFFFFFFFF);
		SDL_BlitSurface(sur,NULL,text_screen,&r);
		fade16(text_screen,i);
		text_flip();
		while(SDL_PollEvent(&ev)) toexit=1;
	}
	for(i=0;(i<23)&&(!toexit);i++)
	{
		while(SDL_PollEvent(&ev)) toexit=1;
		SDL_Delay(100);
	}
	for(i=0;(i<128)&&(!toexit);i+=16)
	{
#ifdef DREAMCAST
		vid_waitvbl();
#else
		SDL_Delay(50);
#endif
		SDL_FillRect(text_screen,NULL,0); //0xFFFFFFFF);
		SDL_BlitSurface(sur,NULL,text_screen,&r);
		fade16(text_screen,i);
		text_flip();
		while(SDL_PollEvent(&ev)) toexit=1;
	}
	for(i=128;(i>-8)&&(!toexit);i-=8)
	{
#ifdef DREAMCAST
		vid_waitvbl();
#else
		SDL_Delay(50);
#endif
		text_draw_background();
		fade16(text_screen,i);
		text_flip();
		while(SDL_PollEvent(&ev)) toexit=1;
	}
	SDL_FreeSurface(sur);
#else
#ifndef DREAMCAST
	chdir(ROM_PREFIX);
#else
//	fs_chdir(ROM_PREFIX);
	fs_chdir("/");//ROM_PREFIX);
#endif
#endif
//	menu_msg_time=SDL_GetTicks();
}