/* Find probe points from lazy pattern */ static int find_probe_point_lazy(Dwarf_Die *sp_die, struct probe_finder *pf) { int ret = 0; char *fpath; if (intlist__empty(pf->lcache)) { const char *comp_dir; comp_dir = cu_get_comp_dir(&pf->cu_die); ret = get_real_path(pf->fname, comp_dir, &fpath); if (ret < 0) { pr_warning("Failed to find source file path.\n"); return ret; } /* Matching lazy line pattern */ ret = find_lazy_match_lines(pf->lcache, fpath, pf->pev->point.lazy_line); free(fpath); if (ret <= 0) return ret; } return die_walk_lines(sp_die, probe_point_lazy_walker, pf); }
void FilePanel::scan_dir( const std::string& root_path, const std::string& rel_path, std::list<PanelItemData>& pid_list, FileListProgress& progress ) { std::string path = add_trailing_slash( root_path ) + rel_path; bool more = true; WIN32_FIND_DATAW find_data; HANDLE h_find = FindFirstFileW( long_path( add_trailing_slash( path ) + L"*" ).data( ), &find_data ); try { if ( h_find == INVALID_HANDLE_VALUE ) { // special case: symlink that denies access to directory, try real path if ( GetLastError( ) == ERROR_ACCESS_DENIED ) { DWORD attr = GetFileAttributesW( long_path( path ).data( ) ); CHECK_SYS( attr != INVALID_FILE_ATTRIBUTES ); if ( attr & FILE_ATTRIBUTE_REPARSE_POINT ) { h_find = FindFirstFileW( long_path( add_trailing_slash( get_real_path( path ) ) + L"*" ).data( ), &find_data ); } else CHECK_SYS( false ); } } if ( h_find == INVALID_HANDLE_VALUE ) { CHECK_SYS( GetLastError( ) == ERROR_NO_MORE_FILES ); more = false; } } catch ( ... ) { if ( flat_mode ) { more = false; } else throw; } ALLOC_RSRC( ; );
int main(int argc, char ** argv) { if(argc != 3) { printf("usage:\n\t./tidy sourcedir targetfile\n"); return; } char fout_path[256]; get_real_path(argv[2],fout_path,256); printf("%s\n",fout_path); unsigned long start = clock(); FILE *fp_out; fp_out = fopen(fout_path,"wb"); if(fp_out == NULL) { return 1; } int deepth = 0; scan_dir(argv[1], deepth, &fp_out); fclose(fp_out); printf("%.3lfs\n", ((double)(clock() - start))/CLOCKS_PER_SEC); return 0; }
void unpfs_walk(Ixp9Req *r) { off_t offset; int ret = 0, i = 0; char *path = zalloc(PATH_MAX), *real_path = NULL; struct unpfs_fid *fid = r->fid->aux; snprintf(path, PATH_MAX, "%s", (!strcmp(fid->path, "/") ? "" : fid->path)); for (offset = strlen(path); i < r->ifcall.twalk.nwname; ++i) { struct stat stbuf; int count = snprintf(path + offset, PATH_MAX - offset, "/%s", r->ifcall.twalk.wname[i]); if (count < 0) { ret = errno; goto out; } offset += count; real_path = get_real_path(path); if (lstat(real_path, &stbuf) < 0) { ret = errno; goto out; } else { r->ofcall.rwalk.wqid[i].type = stbuf.st_mode & S_IFMT; if (S_ISDIR(stbuf.st_mode)) r->ofcall.rwalk.wqid[i].type |= P9_QTDIR; r->ofcall.rwalk.wqid[i].version = 0; r->ofcall.rwalk.wqid[i].path = stbuf.st_ino; zfree(&real_path); } } if (r->fid->fid == r->newfid->fid) { unpfs_log(LOG_INFO, "%s: fid and newfid equals: fid=%u newfid=%u\n", __func__, r->fid->fid, r->newfid->fid); } r->newfid->aux = r->ifcall.twalk.nwname ? unpfs_fid_new(path, r->ofcall.rwalk.wqid[i - 1].type) : unpfs_fid_clone(fid); unpfs_log(LOG_INFO, "%s: newfid: fid=%u fid->path=%s fid->real_path=%s\n", __func__, r->newfid->fid, ((struct unpfs_fid *)(r->newfid->aux))->path, ((struct unpfs_fid *)(r->newfid->aux))->real_path); r->ofcall.rwalk.nwqid = i; out: zfree(&path); zfree(&real_path); respond(r, ret); }
void change_path(t_data *data, char *pwd_asked, char *start_pwd, bool go_home) { char *act_pwd; int j; if (start_pwd == NULL) return ; if (go_home) return (go_to_home(data)); if ((act_pwd = malloc(sizeof(char) * my_strlen(start_pwd) + 1)) == NULL) exit(1); my_bzero(act_pwd, my_strlen(start_pwd) + 1); my_strcpy(act_pwd, start_pwd); act_pwd = get_real_path(pwd_asked, act_pwd); j = get_pos_from_env(data, "PWD"); free(data->env[j]); data->env[j] = act_pwd; free(data->pwd); data->pwd = my_strdup(act_pwd); }
int main(int argc, char *argv[]) { GtkBuilder *builder; GString *txt = g_string_new_len("", 20); char filepad[100]; unsigned short i, mask=0; GdkScreen* screen = NULL; int xx, yy, screen_width, screen_height; InitAudio(); pad = get_real_path(); // get the path of the executable sprintf(filepad, "%s/.lock", pad); setlock(filepad, 10, TRUE); // disable multiple instances for at least 10 seconds g_thread_init (NULL); display = XOpenDisplay(0); if (display == NULL) exit(1); gtk_set_locale(); gtk_init(&argc, &argv); builder = gtk_builder_new (); sprintf(filepad, "%s/%s.glade", pad, SKIN); gtk_builder_add_from_file(builder, filepad, NULL); gtk_builder_connect_signals (builder, NULL); // set widgets to be handled by the event handlers window = GW ("window"); preferences = GW ("preferences"); lookup = GW ("lookup"); fontbutton = GW ("fontbutton1"); drag = GW ("dragbar"); debug = GW ("debug"); papier = GW ("drawingarea1"); colorbutton1 = GW ("colorbutton1"); colorbutton2 = GW ("colorbutton2"); checkbutton1 = GW ("checkbutton1"); entry1 = GW ("entry1"); entry2 = GW ("entry2"); gtktable1 = GW ("table1"); checkbutton8 = GW ("checkbutton8"); checkbutton9 = GW ("checkbutton9"); textview1 = GW ("textview1"); entry16 = GW ("entry16"); combobox1 = GW ("combobox1"); scrolled = GW ("scrolledwindow2"); opacity = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "adjustment1")); speed = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "adjustment2")); textbuffer1 = GTK_TEXT_BUFFER(gtk_builder_get_object (builder, "textbuffer1")); for (i=0; i<sizeof(unsigned short); i++) { // set each bit of mask mask <<= 8; mask |= 0xFF; } // fill the struct that keeps the 7 recognize buttons & checkboxes (in preferences) for (i=0; i<7; i++) { g_string_sprintf(txt, "checkbutton%d", i+2); modebits[i].check = GTK_WIDGET(gtk_builder_get_object (builder, txt->str)); g_string_sprintf(txt, "button%d", i+3); modebits[i].button = GTK_WIDGET(gtk_builder_get_object (builder, txt->str)); switch (i) { case 0: modebits[i].bit = (GB1|GB2); modebits[i].mask = ((GB1|GB2) ^ mask); break; case 1: modebits[i].bit = BIG5; modebits[i].mask = (BIG5 ^ mask); break; case 2: modebits[i].bit = DIGITS; modebits[i].mask = (DIGITS ^ mask); break; case 3: modebits[i].bit = LOWERCASE; modebits[i].mask = (LOWERCASE ^ mask); break; case 4: modebits[i].bit = UPPERCASE; modebits[i].mask = (UPPERCASE ^ mask); break; case 5: modebits[i].bit = PUNC; modebits[i].mask = (PUNC ^ mask); break; case 6: modebits[i].bit = DEFAULT; modebits[i].mask = (DEFAULT ^ mask); break; } } // fill the structure that keeps the 13 labels for the keys (preferences) for (i=0; i<13; i++) { g_string_sprintf(txt, "button%d", i+10); conf.defkey[i].button = GTK_WIDGET(gtk_builder_get_object (builder, txt->str)); g_string_sprintf(txt, "entry%d", i+3); conf.defkey[i].entry = GTK_WIDGET(gtk_builder_get_object (builder, txt->str)); conf.defkey[i].key = 0; } // place a simple combobox for the input selection (preferences) combo = gtk_combo_box_new_text(); gtk_table_attach_defaults(GTK_TABLE(gtktable1), combo, 1, 2, 2, 3); gtk_widget_show (combo); // get events and labels for the 9 candidates for (int i=0; i< 9; i++) { g_string_sprintf(txt, "knop%d", i+1); knop[i] = GTK_WIDGET (gtk_builder_get_object (builder, txt->str)); g_string_sprintf(txt, "event%d", i+1); event[i] = GTK_WIDGET (gtk_builder_get_object (builder, txt->str)); } // set events for paste and backspace entries (preferences) g_signal_connect(entry1, "key_press_event", G_CALLBACK(on_key_press), NULL); g_signal_connect(entry1, "key_release_event", G_CALLBACK(on_key_release), NULL); g_signal_connect(entry2, "key_press_event", G_CALLBACK(on_key_press), NULL); g_signal_connect(entry2, "key_release_event", G_CALLBACK(on_key_release), NULL); if (!create_wtpen_window()) exit(1); wtpen_init(); g_object_unref (G_OBJECT (builder)); gtk_widget_show_all(GTK_WIDGET(window)); for (i=0; i<NUMKEYS; i++) hotkey[i] = 0; // reset all hotkeys // load cedict from file sprintf(filepad, "%s/data", pad); import_cedict(filepad); // load settings from file sprintf(filepad, "%s/xpen.cfg", pad); load_preferences(filepad); // set background and shape sprintf(filepad, "%s/%s.png", pad, SKIN); set_window_shape(filepad); // some styles to be used in the cedict browser (lookup window)一 gtk_text_buffer_create_tag(textbuffer1, "mark", "background", "yellow", "foreground", "black", NULL); gtk_text_buffer_create_tag(textbuffer1, "bold", "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_buffer_create_tag(textbuffer1, "character", "font", conf.font, "scale", 1.3, NULL); gtk_text_buffer_create_tag(textbuffer1, "translation", "scale", 0.9, NULL); gtk_text_buffer_create_tag(textbuffer1, "pinyin", "scale", 1.1, NULL); ready = TRUE; // let_configure_event() know that it can start its setup // start monitoring system-wide keypresses g_thread_create (intercept_key_thread, NULL, FALSE, NULL); // make sure the window positions and size are legal screen = gtk_window_get_screen(GTK_WINDOW(window)); // get screen size screen_width = gdk_screen_get_width(screen); screen_height = gdk_screen_get_height(screen); xx = MAX(MIN(screen_width-width, conf.x), 0); // set the position of the main window yy = MAX(MIN(screen_height-height, conf.y), 0); gtk_widget_set_uposition(window, xx, yy); xx = MIN(screen_width, conf.dx); // set the size of the lookup window yy = MIN(screen_height, conf.dy); gtk_widget_set_usize(lookup, xx, yy); xx = MAX(MIN(screen_width-conf.dx, conf.lx), 0); // set the position of the lookup window yy = MAX(MIN(screen_height-conf.dy, conf.ly), 0); gtk_widget_set_uposition(lookup, xx, yy); g_timeout_add (100, checkfocus, NULL); // check the inputfocus (each 1/10s) ////////////////////////////////////////////////////////////// //on_full_screen_button_pressed(); // start the full screen mode ////////////////////////////////////////////////////////////// gtk_main(); // start the main loop sprintf(filepad, "%s/.lock", pad); // remove the lock setlock(filepad, 0, FALSE); // save all settings to file sprintf(filepad, "%s/xpen.cfg", pad); save_preferences (filepad); g_free(pad); free_all(); wtpen_window_done(); wtlib_done(); SDL_CloseAudio(); SDL_Quit(); //on_full_screen_button_pressed(); return 0; }