Esempio n. 1
0
int create_folders(char *path) {
    /*
     * Recursively create all folders for the given path. Returns -1 on
     * failure and 0 on success.
     */

    char tmp[2048];
    char *p = NULL;
    int success;
    size_t len;

    tmp[0] = 0;
    strcat(tmp, path);
    len = strlen(tmp);

    if (tmp[len - 1] == PATHSEP)
        tmp[len - 1] = 0;

    for (p = tmp + 1; *p; p++) {
        if (*p == PATHSEP && *(p-1) != ':') {
            *p = 0;
            success = create_folder(tmp);
            if (success != -2 && success != 0)
                return success;
            *p = PATHSEP;
        }
    }

    success = create_folder(tmp);
    if (success != -2 && success != 0)
        return success;

    return 0;
}
Esempio n. 2
0
void outdata::write_final_data(class_worker &worker, class_stats &stats){
    if (worker.team->is_commander()) {
        folder = "outdata/final/";
        create_folder(folder);
        string name_E       = folder + string("E.dat");
        string name_M       = folder + string("M.dat");
        string name_T       = folder + string("T.dat");
        string name_s       = folder + string("s.dat");
        string name_c       = folder + string("c.dat");
        string name_m       = folder + string("m.dat");
        string name_u       = folder + string("u.dat");
        string name_f       = folder + string("f.dat");
        string name_x       = folder + string("x.dat");
        string name_dos1D   = folder + string("dos1D.dat");
        string name_dos     = folder + string("dos.dat");
        string name_D       = folder + string("D.dat");
        string name_F       = folder + string("F.dat");
        string name_P       = folder + string("P.dat");

        write_to_file(stats.E_avg, name_E);
        write_to_file(stats.M_avg, name_M);
        write_to_file(stats.T, name_T);
        write_to_file(stats.s_avg, name_s);
        write_to_file(stats.c_avg, name_c);
        write_to_file(stats.m_avg, name_m);
        write_to_file(stats.u_avg, name_u);
        write_to_file(stats.f_avg, name_f);
        write_to_file(stats.x_avg, name_x);
        write_to_file(stats.dos1D_avg, name_dos1D);
        write_to_file(stats.dos_avg, name_dos);
        write_to_file(stats.D_avg, name_D);
        write_to_file(stats.F_avg, name_F);
        write_to_file(stats.P_avg, name_P);

        name_s          = folder + string("s_err.dat");
        name_c          = folder + string("c_err.dat");
        name_m          = folder + string("m_err.dat");
        name_u          = folder + string("u_err.dat");
        name_f          = folder + string("f_err.dat");
        name_x          = folder + string("x_err.dat");
        name_dos1D      = folder + string("dos1D_err.dat");
        name_dos        = folder + string("dos_err.dat");
        name_D          = folder + string("D_err.dat");
        name_F          = folder + string("F_err.dat");
        name_P          = folder + string("P_err.dat");

        write_to_file(stats.s_err, name_s);
        write_to_file(stats.c_err, name_c);
        write_to_file(stats.m_err, name_m);
        write_to_file(stats.u_err, name_u);
        write_to_file(stats.f_err, name_f);
        write_to_file(stats.x_err, name_x);
        write_to_file(stats.dos1D_err, name_dos1D);
        write_to_file(stats.dos_err, name_dos);
        write_to_file(stats.D_err, name_D);
        write_to_file(stats.F_err, name_F);
        write_to_file(stats.P_err, name_P);
    }
}
Esempio n. 3
0
static void create_folder_tree()
{
	struct message_folder *parent, *child;

	folder_tree = create_folder("/", "FILTER (!BOUND(?msg))");

	parent = create_folder("telecom", "FILTER (!BOUND(?msg))");
	folder_tree->subfolders = g_slist_append(folder_tree->subfolders,
								parent);

	child = create_folder("msg", "FILTER (!BOUND(?msg))");
	parent->subfolders = g_slist_append(parent->subfolders, child);

	parent = child;

	child = create_folder("inbox", "?msg nmo:isSent \"false\" ; "
				"nmo:isDeleted \"false\" ; "
				"nmo:isDraft \"false\". ");
	parent->subfolders = g_slist_append(parent->subfolders, child);

	child = create_folder("sent", "?msg nmo:isDeleted \"false\" ; "
				"nmo:isSent \"true\" . ");
	parent->subfolders = g_slist_append(parent->subfolders, child);

	child = create_folder("deleted", "?msg nmo:isDeleted \"true\" . ");
	parent->subfolders = g_slist_append(parent->subfolders, child);
}
Esempio n. 4
0
HRESULT Camera::takePicture(HWND hwndOwner,LPTSTR pszFilename) 
{
    HRESULT         hResult = S_OK;
#if defined(_WIN32_WCE) && !defined( OS_PLATFORM_MOTCE )
    SHCAMERACAPTURE shcc;

    StringW root;
    convertToStringW(rho_rhodesapp_getblobsdirpath(), root);
    wsprintf( pszFilename, L"%s", root.c_str() );

	create_folder(pszFilename);

    //LPCTSTR szExt = wcsrchr(pszFilename, '.');
    TCHAR filename[256];
	generate_filename(filename,L".jpg");

    // Set the SHCAMERACAPTURE structure.
    ZeroMemory(&shcc, sizeof(shcc));
    shcc.cbSize             = sizeof(shcc);
    shcc.hwndOwner          = hwndOwner;
    shcc.pszInitialDir      = pszFilename;
    shcc.pszDefaultFileName = filename;
    shcc.pszTitle           = TEXT("Camera");
    shcc.VideoTypes			= CAMERACAPTURE_VIDEOTYPE_MESSAGING;
    shcc.nResolutionWidth   = 176;
    shcc.nResolutionHeight  = 144;
    shcc.nVideoTimeLimit    = 15;
    shcc.Mode               = CAMERACAPTURE_MODE_STILL;

    // Display the Camera Capture dialog.
    hResult = SHCameraCapture(&shcc);

    // The next statements will execute only after the user takes
    // a picture or video, or closes the Camera Capture dialog.
    if (S_OK == hResult) {
        LPTSTR fname = get_file_name(shcc.szFile,pszFilename);
		if (fname) {
			StringCchCopy(pszFilename, MAX_PATH, fname);
			free(fname);
		} else {
            LOG(ERROR) + "takePicture error get file: " + shcc.szFile;

			hResult = E_INVALIDARG;
		}
    }else
    {
        LOG(ERROR) + "takePicture failed with code: " + LOGFMT("0x%X") + hResult;
    }
#endif //_WIN32_WCE

    return hResult;
}
Esempio n. 5
0
bool Database::folder_create(void) {
  _BOOL_ success = create_folder(directory_path.c_str(), NULL);
  if(success == 0) {
    _ERR_ err = _OBTAIN_LAST_ERROR;
    // These are windows api macros that must be changed later on for compatibility reasons.
    if(err == ERROR_ALREADY_EXISTS) {
      db_error = get_error_msg(Errors::error_folder_already_exists);
    } else if(err == ERROR_PATH_NOT_FOUND) {
      db_error = get_error_msg(Errors::error_path_not_found);
    }
  }
  return bool(success);
}
Esempio n. 6
0
HRESULT Camera::selectPicture(HWND hwndOwner,LPTSTR pszFilename) {
	RHO_ASSERT(pszFilename);
	OPENFILENAMEEX ofn = {0};

	ofn.lStructSize     = sizeof(ofn);
	ofn.lpstrFilter     = NULL;
	ofn.lpstrFile       = pszFilename;
	ofn.nMaxFile        = MAX_PATH;
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrTitle      = _T("Select an image");
	ofn.ExFlags         = OFN_EXFLAG_THUMBNAILVIEW|OFN_EXFLAG_NOFILECREATE|OFN_EXFLAG_LOCKDIRECTORY;

	if (GetOpenFileNameEx(&ofn)) {
		HRESULT hResult = S_OK;

		TCHAR rhoroot[MAX_PATH];
		wchar_t* root  = wce_mbtowc(RhoGetRootPath());
		wsprintf(rhoroot,L"%s%s",root,L"apps\\public\\db-files");
		free(root);

		create_folder(rhoroot);

		TCHAR filename[256];
		generate_filename(filename);
		
		int len = wcslen(rhoroot) + wcslen(L"\\") + wcslen(filename);
		wchar_t* full_name = (wchar_t*) malloc((len+2)*sizeof(wchar_t));
		wsprintf(full_name,L"%s\\%s",rhoroot,filename);

		if (copy_file(pszFilename,full_name)) {
			StringCchCopy(pszFilename, MAX_PATH, filename);	
		} else {
			hResult = E_INVALIDARG;
		}

		free(full_name);

		return hResult;
	} else if (GetLastError()==ERROR_SUCCESS) {
		return S_FALSE; //user cancel op
	}
	return E_INVALIDARG;
}
Esempio n. 7
0
HRESULT Camera::takePicture(HWND hwndOwner,LPTSTR pszFilename) {
    HRESULT         hResult;
    SHCAMERACAPTURE shcc;

    wchar_t* root  = wce_mbtowc(RhoGetRootPath());
    wsprintf(pszFilename,L"%s%s",root,L"apps\\public\\db-files");
    free(root);

	create_folder(pszFilename);

    TCHAR filename[256];
	generate_filename(filename);

    // Set the SHCAMERACAPTURE structure.
    ZeroMemory(&shcc, sizeof(shcc));
    shcc.cbSize             = sizeof(shcc);
    shcc.hwndOwner          = hwndOwner;
    shcc.pszInitialDir      = pszFilename;
    shcc.pszDefaultFileName = filename;
    shcc.pszTitle           = TEXT("Camera");
    shcc.VideoTypes			= CAMERACAPTURE_VIDEOTYPE_MESSAGING;
    shcc.nResolutionWidth   = 176;
    shcc.nResolutionHeight  = 144;
    shcc.nVideoTimeLimit    = 15;
    shcc.Mode               = CAMERACAPTURE_MODE_STILL;

    // Display the Camera Capture dialog.
    hResult = SHCameraCapture(&shcc);

    // The next statements will execute only after the user takes
    // a picture or video, or closes the Camera Capture dialog.
    if (S_OK == hResult) {
        LPTSTR fname = get_file_name(shcc.szFile,pszFilename);
		if (fname) {
			StringCchCopy(pszFilename, MAX_PATH, fname);
			free(fname);
		} else {
			hResult = E_INVALIDARG;
		}
    }

    return hResult;
}
static HRESULT WINAPI
NewMenu_ContextMenu3_InvokeCommand(IContextMenu3 *iface, LPCMINVOKECOMMANDINFO info)
{
    NewMenuImpl *This = impl_from_IContextMenu3(iface);
    IShellBrowser *browser;
    IShellView *view = NULL;
    HRESULT hr = E_FAIL;

    TRACE("(%p)->(%p)\n", This, info);

    /* New Folder */
    if (info->lpVerb == 0)
    {
        if ((browser = (IShellBrowser *)SendMessageA(info->hwnd, CWM_GETISHELLBROWSER, 0, 0)))
        {
            if (FAILED(IShellBrowser_QueryActiveShellView(browser, &view)))
                view = NULL;
        }
        hr = create_folder(This, view);
        if (view) IShellView_Release(view);
    }

    return hr;
}
Esempio n. 9
0
int data_compiler_main(bx::CommandLine* cmdline)
{
    delete_file(DC_RESULT);

    int err = kErrorSuccess;
    uint32_t timeMS = ::GetTickCount();

    LOG_INIT("DataCompilerLog.html", "Data Compiler");
    MemoryConfig cfg;
    memset(&cfg, 0, sizeof cfg);
    cfg.m_debugMemSize = SIZE_MB(2);
    g_memoryMgr.init(cfg);

#ifdef DC_DUMP_PROFILE
    g_profiler.init(TOTAL_BLOCK_NUM);
#endif

    register_engine_factories();

    g_config = new DC_Config;
    const char* inputChar = cmdline->findOption('i');
    if(!inputChar) inputChar = "intermediate";
    const char* outputFolderChar = cmdline->findOption('o');
    if(!outputFolderChar) outputFolderChar = "data";
    const char* threadChar = cmdline->findOption('t');
    if(threadChar) g_config->m_numThreads = atoi(threadChar);
    g_config->m_ignoreTextures = cmdline->hasArg("ignore_texture");
    g_config->m_slient = cmdline->hasArg("slient");
    g_config->m_bundled = cmdline->hasArg("bundle");
    g_config->m_forceRecompile = cmdline->hasArg('b');

    create_folder("data");
    g_config->m_database.load(DC_DATABASE);

    g_config->m_inputDir = inputChar;
    string_replace(g_config->m_inputDir, "\\", "/");
    add_trailing_slash(g_config->m_inputDir);
    g_config->m_topFolder = get_top_folder(g_config->m_inputDir);
    g_config->m_outputDir = input_to_output(g_config->m_inputDir);

    ENGINE_ASSERT(g_config->m_topFolder.length(), "top folder error.");
    string_replace(g_config->m_outputDir, "\\", "/");
    add_trailing_slash(g_config->m_outputDir);
    std::string secondFolder = remove_top_folder(g_config->m_outputDir);
    if(secondFolder.length()) g_config->m_packageName = get_top_folder(secondFolder);
    LOGI("input = %s, output = %s, top-folder = %s, package-name=%s",
        g_config->m_inputDir.c_str(),
        g_config->m_outputDir.c_str(),
        g_config->m_topFolder.c_str(),
        g_config->m_packageName.c_str());

    level_processing();
    resources_process();
    if(g_config->m_compilers.size() < 10) g_config->m_numThreads = 0;
    if(g_config->m_numThreads < 2)
    {
        for(size_t i=0; i<g_config->m_compilers.size(); ++i)
        {
            g_config->m_compilers[i]->go();
        }
    }
    else
    {
        const int maxThreads = 8;
        if(g_config->m_numThreads > maxThreads) g_config->m_numThreads = maxThreads;
        uint32_t totalNum = g_config->m_compilers.size();
        uint32_t numPerThread = totalNum / g_config->m_numThreads + 1;
        bx::Thread* threads[maxThreads];
        std::vector<BaseCompiler*> compilers[maxThreads];
        uint32_t currIndex = 0;

        for (int i=0; i<g_config->m_numThreads; ++i)
        {
            uint32_t elementNum = numPerThread;
            uint32_t numLeft = totalNum - currIndex;
            if(numLeft < elementNum) elementNum = numLeft;
            if(elementNum == 0) continue;
            std::vector<BaseCompiler*>& comArray = compilers[i];
            comArray.resize(elementNum);
            memcpy(&comArray[0], &g_config->m_compilers[currIndex], elementNum*sizeof(void*));
            currIndex += elementNum;
            if(i == 0) continue;
            threads[i] = new bx::Thread();
            threads[i]->init(thread_compile, &comArray);
        }
        //main thread with other threads.
        thread_compile(&compilers[0]);
        for (int i=1; i<g_config->m_numThreads; ++i)
        {
            delete threads[i];
        }
    }
    g_config->post_process();
    package_processing();

    timeMS = ::GetTickCount() - timeMS;
    if(!g_config->m_slient) g_config->m_error.show_error();
    g_config->m_database.save(DC_DATABASE);
    g_config->m_database.m_files.clear();
    SAFE_DELETE(g_config);

#ifdef DC_DUMP_PROFILE
    g_profiler.dump_to_file("data_compiler_profile.txt", true, true);
    g_profiler.shutdown();
#endif

    g_memoryMgr.shutdown();

    LOGD("******************************************************");
    LOGD("******************************************************");
    LOGD("* TOTAL TIME COST = %d[MS] *", timeMS);
    LOGD("******************************************************");
    LOGD("******************************************************");
    LOG_TERM();

	return err;
}
Esempio n. 10
0
int main()
{
	User new_user;                       //初始化用户信息
	new_user.username = "******";
	new_user.password = "******";
	user.push_back(new_user);

	string username;
	string password;
	string command;
	string subcommand;
	string temp_path;
	char t;
	init();
	save();
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
	cout << "welcome to system" << endl;
	cout << "please login" << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED);
	while (1)
	{
		username = "";
		password = "";
		cout << "username:"******"password:"******"username or password error" << endl;
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED);
        }
	}
	system("cls");
	getline(cin, command);
	while (1)
	{
	    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
		cout << username;
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED);
		cout << "@filesystem ";
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
		if (path.size() == 1)
			cout << "/";
		else
		{
			for (auto p : path)
			{
				if (p == 0)
					continue;
				cout << "/" << catalog[p].info.name;
			}
		}
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED);
		cout << endl << ">";
		getline(cin, command);
		stringstream command_stream(command);
		command_stream >> subcommand;
		if (subcommand == "")
		{

		}
		else if (subcommand == "cd")
		{
			change_path(command);
		}
		else if (subcommand == "ls")
		{
			show_folder(command);
		}
		else if (subcommand == "create")
		{
			create(command);
		}
		else if (subcommand == "mkdir")
		{
			create_folder(command);
		}
		else if (subcommand == "delete")
		{
			delete_file(command);
		}
		else if (subcommand == "edit")
		{
			edit(command);
		}
		else if (subcommand == "search")
		{
			search_file(command);
		}
		else if (subcommand == "open")
		{
			open_file(command);
		}
		else if (subcommand == "close")
		{
			close_file(command);
		}
		else if (subcommand == "cp")
		{
			copy(command);
		}
		else if (subcommand == "mv")
		{
			move(command);
		}
		else if (subcommand == "bs"){
            backstage();
		}
		else if (subcommand == "l"){
            l();
		}
		else if (subcommand == "info"){
			info();
		}
		else if (subcommand == "format")
		{
			remove("disk.txt");
			remove("diskdata.txt");
			init();
		}
		else
		{
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
			cout << "command not found" << endl;
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED);
		}
		cout << endl;
		save();
		command = "";
		subcommand = "";
	}
}
Esempio n. 11
0
void outdata::create_iteration_folder_worker(const int iter){
    set_foldername_to_iteration(iter);
    create_folder(folder);
}
Esempio n. 12
0
void outdata::create_iteration_folder_commander(class_worker &worker, int iter){
    if(worker.team->is_commander()){
        set_foldername_to_iteration(iter);
        create_folder(folder);
    }
}
Esempio n. 13
0
void outdata::create_set_folder(string folder_name){
    folder = folder_name;
    create_folder(folder);
}
Esempio n. 14
0
int main()
{
	string username;
	string password;
	string command;
	string subcommand;
	string temp_path;
	char t;
	load_user();
	init();
	save();
	while (1)
	{
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
		cout << "welcome to system" << endl;
		cout << "please login" << endl;
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
		while (1)
		{
			username = "";
			password = "";
			cout << "username:"******"password:"******"username or password error" << endl;
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
			}
		}
		system("cls");
		getline(cin, command);
		while (1)
		{
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
			cout << username;
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED);
			cout << "@filesystem ";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
			if (path.size() == 1)
				cout << "/";
			else
			{
				for (auto p : path)
				{
					if (p == 0)
						continue;
					cout << "/" << catalog[p].info.name;
				}
			}
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
			cout << endl << ">";
			getline(cin, command);
			stringstream command_stream(command);
			command_stream >> subcommand;
			if (subcommand == "")
			{

			}
			else if (subcommand == "cd")
			{
				change_path(command);
			}
			else if (subcommand == "ls")
			{
				show_folder(command);
			}
			else if (subcommand == "create")
			{
				create(command);
			}
			else if (subcommand == "mkdir")
			{
				create_folder(command);
			}
			else if (subcommand == "delete")
			{
				delete_file(command);
			}
			else if (subcommand == "edit")
			{
				edit(command);
			}
			else if (subcommand == "search")
			{
				search_file(command);
			}
			else if (subcommand == "open")
			{
				open_file(command);
			}
			else if (subcommand == "close")
			{
				close_file(command);
			}
			else if (subcommand == "cp")
			{
				copy(command);
			}
			else if (subcommand == "mv")
			{
				move(command);
			}
			else if (subcommand == "bs"){
				backstage();
			}
			else if (subcommand == "l"){
				l();
			}
			else if (subcommand == "info"){
				info();
			}
			else if (subcommand == "format")
			{
				char c;
				cout << "Are you sure you want to format the disk?(y/N)";
				c = _getch();
				if (c == 'n' || c == 'N' || c == '\r')
				{
					cout << c << endl;
					continue;
				}
				else if (c == 'y' || c == 'Y')
				{
					remove("disk.txt");
					remove("diskdata.txt");
					init();
					cout << c << "\nformat complete" << endl;
				}
			}
			else if (subcommand == "useradd")
			{
				add_user(command);
			}
			else if (subcommand == "userdelete")
			{
				delete_user(command);
			}
			else if (subcommand == "passwd")
			{
				change_password(command);
			}
			else if (subcommand == "clear")
			{
				system("cls");
			}
			else if (subcommand == "exit")
			{
				system("cls");
				break;
			}
			else
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
				cout << "command not found" << endl;
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
			}
			cout << endl;
			save();
			command = "";
			subcommand = "";
		}
	}
}
Esempio n. 15
0
int havok_convert_main(bx::CommandLine* cmdline)
{
#ifdef HAVOK_COMPILE
    uint32_t timeMS = GetTickCount();

    int err = kErrorSuccess;
    LOG_INIT("HavokConverterLog.html", "Havok Converter");
    MemoryConfig cfg;
    memset(&cfg, 0, sizeof(cfg));
    cfg.m_debugMemSize = SIZE_MB(2);
    cfg.m_initHavok = true;
    cfg.m_havokFrameMemSize = 0;
    cfg.m_havokMonitorMemSize = 0;
    g_memoryMgr.init(cfg);

#ifdef HC_DUMP_PROFILE
    g_profiler.init(64);
#endif

    register_engine_factories();

    g_hc_config = new HC_Config;
    g_hc_config->m_packNormal = cmdline->hasArg("packnormal");
    g_hc_config->m_packUV = cmdline->hasArg("packuv");
    g_hc_config->m_slient = cmdline->hasArg("slient");
    g_hc_config->m_verbose = cmdline->hasArg("verbose");
    g_hc_config->m_merge = !cmdline->hasArg('b');

    Actor_Config config;
    ActorConverter* converter = 0;
    const char* mode = cmdline->findOption('m');
    if(!mode)
        mode = "model";

    const char* class_name = cmdline->findOption('c');
    if(!class_name)
        class_name = "level_geometry";

    const char* input = cmdline->findOption('f');
    const char* output = cmdline->findOption('o');
    if(!input)
    {
        g_hc_config->m_error.add_error("havok convert must specific f args!");
        err = kErrorArg;
        goto error_exit;
    }

    config.m_exportMode = mode;
    config.m_input = input;
    config.m_exportName = getFileName(input);
    config.m_exportFolder = "";
    config.m_rootPath = "";
    config.m_exportClass = class_name;

    if(output)
    {
        std::string output_path = output;
        string_replace(output_path, "\\", "/");
        if (str_begin_with(output_path, "./"))
        {
            output_path = output_path.substr(2, output_path.length() - 2);
        }
        if(!str_begin_with(output_path, INTERMEDIATE_PATH))
            config.m_exportFolder = std::string(INTERMEDIATE_PATH) + output_path;
        else
            config.m_exportFolder = output_path;
        add_trailing_slash(config.m_exportFolder);
        std::string path = config.m_exportFolder;
        string_replace(path, INTERMEDIATE_PATH, "");
        config.m_rootPath = path;
        LOGD("export-folder=%s *********** root-folder=%s", config.m_exportFolder.c_str(), config.m_rootPath.c_str());
    }
    else
    {
        config.m_exportFolder = TEMP_PATH;
    }
    config.m_output = config.m_exportFolder + config.m_exportName + "." + std::string(EngineNames::ACTOR);

    config.m_loader = new hkLoader;
    hkRootLevelContainer* rlc = config.m_loader->load(config.m_input.c_str());
    if (!rlc)
    {
        g_hc_config->m_error.add_error("can not load input havok file %s", config.m_input.c_str());
        err = kErrorLoadHavok;
        goto error_exit;
    }

    config.m_rlc = rlc;
    create_folder(config.m_exportFolder);
    hkxEnvironment* env = LOAD_OBJECT(rlc, hkxEnvironment);
    if(env)
    {
        hkStringBuf env_str;
        env->convertToString(env_str);
        LOGI(env_str.cString());
        config.m_assetFolder = env->getVariableValue("assetFolder");
        config.m_assetPath = env->getVariableValue("assetPath");
    }

    hkaAnimationContainer* ac = LOAD_OBJECT(rlc, hkaAnimationContainer);
    hkxScene* scene = LOAD_OBJECT(rlc,hkxScene);
    hkpPhysicsData* data = LOAD_OBJECT(rlc, hkpPhysicsData);

    config.m_scene = scene;
    config.m_animation = ac;
    config.m_physics = data;

    if(config.m_exportMode == "model")
    {
        if(!scene || !scene->m_rootNode)
        {
            g_hc_config->m_error.add_error("hkx file do not has root scene node.");
            goto error_exit;
        }
        converter = new StaticModelConverter;
        converter->setClass(config.m_exportClass);
    }
    else if(config.m_exportMode == "skin")
    {
        converter = new CharacterConverter;
        converter->setClass("character");
    }
    else if(config.m_exportMode == "level")
    {
        converter = new LevelConverter;
        config.m_output = config.m_exportFolder + config.m_exportName + "." + std::string(EngineNames::LEVEL);
    }
    else if(config.m_exportMode == "animation")
    {
        converter = new AnimationConverter;
        config.m_output = config.m_exportFolder + config.m_exportName + "." + std::string(EngineNames::ANIMATION);
    }
    if(!converter)
    {
        g_hc_config->m_error.add_error("havok converter export mode error.");
        err = kErrorArg;
        goto error_exit;
    }

    converter->m_config = &config;
    converter->setName(config.m_exportName);
    if(config.m_exportMode == "skin")
    {
        converter->process(ac);
    }
    else if(config.m_exportMode == "animation")
    {
        converter->process(ac);
    }
    else
    {
        converter->process(scene);
    }
    converter->postProcess();
    converter->serializeToFile(config.m_output.c_str());

error_exit:
    SAFE_REMOVEREF(converter);
    SAFE_REMOVEREF(config.m_loader);
    if(!g_hc_config->m_slient)
        g_hc_config->m_error.show_error();
    SAFE_DELETE(g_hc_config);

#ifdef HC_DUMP_PROFILE
    g_profiler.dump_to_file("havokconverter_profile.txt", true, true);
    g_profiler.shutdown();
#endif

    g_memoryMgr.shutdown();

    timeMS = GetTickCount() - timeMS;
    LOGD("******************************************************");
    LOGD("******************************************************");
    LOGD("* TOTAL TIME COST = %d[MS]", timeMS);
    LOGD("******************************************************");
    LOGD("******************************************************");

    LOG_TERM();
#endif
	return kErrorSuccess;
}
Esempio n. 16
0
File: m_draft.c Progetto: ella13/nmh
char *
m_draft (char *folder, char *msg, int use, int *isdf)
{
    register char *cp;
    register struct msgs *mp;
    static char buffer[BUFSIZ];

    if (*isdf == -1 || folder == NULL || *folder == '\0') {
	if (*isdf == -1 || (cp = context_find ("Draft-Folder")) == NULL) {
	    *isdf = 0;
	    return m_maildir (msg && *msg ? msg : draft);
	} else {
	    folder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
		    *cp != '@' ? TFOLDER : TSUBCWF);
	}
    }
    *isdf = 1;
    
    chdir (m_maildir (""));
    strncpy (buffer, m_maildir (folder), sizeof(buffer));

    create_folder (buffer, 0, done);

    if (chdir (buffer) == -1)
	adios (buffer, "unable to change directory to");

    if (!(mp = folder_read (folder)))
	adios (NULL, "unable to read folder %s", folder);

    /*
     * Make sure we have enough message status space for all
     * the message numbers from 1 to "new", since we might
     * select an empty slot.  If we add more space at the
     * end, go ahead and add 10 additional slots.
     */
    if (mp->hghmsg >= mp->hghoff) {
	if (!(mp = folder_realloc (mp, 1, mp->hghmsg + 10)))
	    adios (NULL, "unable to allocate folder storage");
    } else if (mp->lowoff > 1) {
	if (!(mp = folder_realloc (mp, 1, mp->hghoff)))
	    adios (NULL, "unable to allocate folder storage");
    }

    mp->msgflags |= ALLOW_NEW;	/* allow the "new" sequence */

    /*
     * If we have been give a valid message name, then use that.
     * Else, if we are given the "use" option, then use the
     * current message.  Else, use special sequence "new".
     */
    if (!m_convert (mp, msg && *msg ? msg : use ? "cur" : "new"))
	done (1);
    seq_setprev (mp);

    if (mp->numsel > 1)
	adios (NULL, "only one message draft at a time!");

    snprintf (buffer, sizeof(buffer), "%s/%s", mp->foldpath, m_name (mp->lowsel));
    cp = buffer;

    seq_setcur (mp, mp->lowsel);/* set current message for folder */
    seq_save (mp);		/* synchronize message sequences  */
    folder_free (mp);		/* free folder/message structure  */

    return cp;
}
Esempio n. 17
0
void control(void)
{
	uint16_t work_slice;
	char c = 0;

	while(c != 27)
	{
		c = getch();
		if(c == 80)
		{
			opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
			if(opt_slice->next_slice != 0)
			{
				cursor.ID_slice = opt_slice->next_slice;
				opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
				cursor.ID_file = opt_slice->ID_file;
				cursor.ID_folder = opt_slice->ID_folder;
			}
			system("cls");
			output_PC();
			//cursor(output_PC)
		}
		if(c == 72)
		{
			opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
			if(opt_slice->prev_slice != 0)
			{
				prev_opt_slice = (opt_slice_init*) &mem[(opt_slice->prev_slice - 1)*32]; 
				if(prev_opt_slice->ID_folder == opt_slice->ID_folder)
				{
					cursor.ID_slice = opt_slice->prev_slice;
					opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
					cursor.ID_file = opt_slice->ID_file;
					cursor.ID_folder = opt_slice->ID_folder;	
				}				
			}
			system("cls");
			output_PC();
			//cursor(output_PC)
		}
		if(c == 13)
		{
			opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
			if(opt_slice->safe == 3)
			{
				cursor.ID_slice = opt_slice->next_slice_folder;
				opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
				cursor.ID_file = opt_slice->ID_file;
				cursor.ID_folder = opt_slice->ID_folder;
			}
			system("cls");
			output_PC();
			//cursor(output_PC)
		}
		if(c == 8)
		{
			opt_slice = (opt_slice_init*) &mem[(cursor.ID_slice - 1)*32];
			if(opt_slice->ID_folder != 1)
			{
				work_slice = find_first_file_in_folder(cursor.ID_slice);			
				opt_slice = (opt_slice_init*) &mem[(work_slice - 1)*32];
				prev_opt_slice = (opt_slice_init*) &mem[(opt_slice->prev_slice - 1)*32]; 								
				
				work_slice = find_first_file_in_folder(opt_slice->prev_slice_folder);
				opt_slice = (opt_slice_init*) &mem[(work_slice - 1)*32];
				cursor.ID_slice = opt_slice->ID_slice;
				cursor.ID_file = opt_slice->ID_file;
				cursor.ID_folder = opt_slice->ID_folder;

				system("cls");
				output_PC();
				//cursor(output_PC)
			}
		}
		if(c == 32)
		{
			system("cls");
			printf("Enter name temporary and value: \n");
			scanf("%s %u", &name_file, &val_temp);
			//getch();
			//printf("Enter value temporary \n");
			//scanf("/u", &val_temp);
			
			create_file(&name_file[0], val_temp);
			system("cls");
			output_PC();
			//cursor(output_PC)	
		}
		if(c == 57)
		{
			system("cls");
			printf("Enter name folder, name first temporary in folder\n and her value: \n ");
			scanf("%s %s %u", &name_folder, &name_file, &val_temp);
			//getch();
			//printf("Enter value temporary \n");
			//scanf("/u", &val_temp);
			
			create_folder(&name_folder[0], &name_file[0], val_temp);
			system("cls");
			output_PC();
			//cursor(output_PC)
		}
		if(c == 56)
		{
			system("cls");
			printf("Enter name temporary and value: \n");
			scanf("%s %u", &name_file, &val_temp);

			change_file(&name_file[0], val_temp);
			system("cls");
			output_PC();
		}
		if(c == 55)
		{
			system("cls");
			printf("Enter name folder: \n");
			scanf("%s", &name_folder);

			change_folder(&name_folder[0]);
			system("cls");
			output_PC();
		}
	}	
}
Esempio n. 18
0
int main(int arg, char *args[])
{
    set_folder_template();
    if(args[1]!=NULL)
    {
        printf("Projeto: %s \n",args[1]);
        if(args[2]!=NULL && verified_folder(args[1]))
        {
            path = args[1];
            printf("Namespace: %s\n",args[2]);
            int verified = verified_namespace(args[2]);
            if(verified==1)
            {
                name_space = args[2];
                printf("criando pasta do modulo \n");
                if(create_folder(args[3]))
                {
                    module = args[3];
                    printf("pasta criada \n");
                    char* option;
                    scanf("tipo do modulo %s\n",&option);
                    printf("%s\n",option);
                }
                else
                {
                    printf("erro ao criar o folder \n");
                }
            }
            else
            {
                printf("não existe namespace com esse nome \n ");
                if(args[2]!=NULL && verified == 0)
                {
                    printf("criando o namespace \n");
                    if(create_folder(args[2]))
                    {
                        name_space = args[2];
                        chdir(args[2]);
                        printf("criando pasta do modulo \n");
                        if(create_folder(args[3]))
                        {
                            printf("pasta criada \n");
                            chdir(args[3]);
                            set_module(args[3]);
                            printf("selecione a opção de módulo que você deseja\n");
                            printf("1. simples(etc/config.xml, diretório controller e Block ).\n2. básico (todos os diretórios e também o arquivo de configuração). \n");
                            int option;
                            printf("escolha o tipo do módulo:\n");
                            scanf("%d",&option);
                            printf("opção escolhida %d\n",option);
                            printf("criando template");
                            create_template(option);
                        }
                        else
                        {
                            printf("erro ao criar o folder \n");
                        }
                    }else{
                        printf("erro ao criar o namespace \n");
                    }
                }else{
                    printf("verifique a estrutura de seu projeto \n");
                }

            }
        }
        else
            printf("Nenhum namespace foi  especificado \n");
    }
    else
    {
        printf("Nenhum Projeto foi especificado \n");
    }
    return 0;
}