void get_full_working_path(TCHAR full_path[BUFF_PATH_SIZE], TCHAR filename [BUFF_PATH_SIZE]){ size_t len = 0; //get_file_dir get_file_dir(full_path); len = _tcslen(full_path); full_path[len] = _T('\\'); _tcscpy_s(&full_path[len + 1], BUFF_PATH_SIZE, filename); }
bool OEFind::get_conf_dir() { char filename[1024]; char dir[1024]; get_exe_path(filename, 1024); get_file_dir(dir, filename, 1024); if (!get_absolute_path(conf_dir, "../conf/OEFind/", dir)) return false; return true; }
int get_bin(t_data *data) { char *path; char *frag; path = data->std.path; data->bin = NULL; while ((frag = get_bin_dir(&path))) { if ((get_file_dir(&data->bin, frag)) == SH_FAIL) return (SH_FAIL); free(frag); } return (SH_OK); }
void ImageIDer::Load(const std::string& filepath) { std::string dir = get_file_dir(filepath); std::locale::global(std::locale("")); std::ifstream fin(filepath.c_str()); std::locale::global(std::locale("C")); std::string line; int id = 1; while (std::getline(fin, line)) { std::string path = dir + "\\" + line; std::string key = path.substr(0, path.find_last_of('.')); // str_replace(key, "\\", "/"); str_replace(key, "/", "\\"); m_ids.insert(std::make_pair(key, id++)); } fin.close(); }
bool sil_load(string file_path) { string cur_dir=get_current_dir(); string file_full_path=get_file_full_path(file_path); set_current_dir(get_file_dir(file_path)); int ip=get_new_code_addr(true); grammar_parser parser; parser.load_file(file_full_path); parser.complie(); bool b_result=false; if(error_printer::get_error_count()==0) { //print_code(); interpret vm(get_top_gener()); vm.run(ip); b_result=true; } set_current_dir(cur_dir); return b_result; }
void read_mosaic_grid_sizes(const char *mosaic_file, int *nx, int *ny) { int ntiles, n; char gridfile[STRING], tilefile[2*STRING]; char dir[STRING]; const int x_refine = 2, y_refine = 2; get_file_dir(mosaic_file, dir); ntiles = get_dimlen(mosaic_file, "ntiles"); for(n = 0; n < ntiles; n++) { get_string_data_level(mosaic_file, "gridfiles", gridfile, &n); sprintf(tilefile, "%s/%s", dir, gridfile); nx[n] = get_dimlen(tilefile, "nx"); ny[n] = get_dimlen(tilefile, "ny"); if(nx[n]%x_refine != 0) error_handler("Error from read_mosaic_grid_sizes: nx is not divided by x_refine"); if(ny[n]%y_refine != 0) error_handler("Error from read_mosaic_grid_sizes: ny is not divided by y_refine"); nx[n] /= x_refine; ny[n] /= y_refine; } }; /* read_mosaic_grid_sizes */
/****************************************************************************** void read_mosaic_grid_data(const char *mosaic_file, const char *name, int nx, int ny, double *data, int level, int ioff, int joff) read mosaic grid information onto model grid. We assume the refinement is 2 right now. We may remove this restriction in the future. nx and ny are model grid size. level is the tile number. ioff and joff to indicate grid location. ioff =0 and joff = 0 for C-cell. ioff=0 and joff=1 for E-cell, ioff=1 and joff=0 for N-cell, ioff=1 and joff=1 for T-cell ******************************************************************************/ void read_mosaic_grid_data(const char *mosaic_file, const char *name, int nx, int ny, double *data, int level, int ioff, int joff) { char tilefile[STRING], gridfile[STRING], dir[STRING]; double *tmp; int ni, nj, nxp, nyp, i, j; get_file_dir(mosaic_file, dir); get_string_data_level(mosaic_file, "gridfiles", gridfile, &level); sprintf(tilefile, "%s/%s", dir, gridfile); ni = get_dimlen(tilefile, "nx"); nj = get_dimlen(tilefile, "ny"); if( ni != nx*2 || nj != ny*2) error_handler("supergrid size should be double of the model grid size"); tmp = (double *)malloc((ni+1)*(nj+1)*sizeof(double)); get_double_data( tilefile, name, tmp); nxp = nx + 1 - ioff; nyp = ny + 1 - joff; for(j=0; j<nyp; j++) for(i=0; i<nxp; i++) data[j*nxp+i] = tmp[(2*j+joff)*(ni+1)+2*i+ioff]; free(tmp); }; /* read_mosaic_grid_data */