extern "C" HMODULE __stdcall dllLoadLibraryExtended(LPCSTR lib_file, LPCSTR sourcedll) { char libname[MAX_PATH + 1] = {}; char libpath[MAX_PATH + 1] = {}; LibraryLoader* dll = NULL; /* extract name */ const char* p = strrchr(lib_file, PATH_SEPARATOR_CHAR); if (p) strcpy(libname, p+1); else strcpy(libname, lib_file); if( libname[0] == '\0' ) return NULL; /* extract path */ getpath(libpath, lib_file); CLog::Log(LOGDEBUG, "LoadLibraryA('%s')", libname); if (sourcedll) { /* also check for invalid paths wich begin with a \ */ if( libpath[0] == '\0' || libpath[0] == PATH_SEPARATOR_CHAR ) { /* use calling dll's path as base address for this call */ getpath(libpath, sourcedll); /* mplayer has all it's dlls in a codecs subdirectory */ if (strstr(sourcedll, "mplayer.dll")) strcat(libpath, "codecs\\"); } } /* if we still don't have a path, use default path */ if( libpath[0] == '\0' ) strcpy(libpath, DEFAULT_DLLPATH); /* msdn docs state */ /* "If no file name extension is specified in the lpFileName parameter, the default library extension .dll is appended. */ /* However, the file name string can include a trailing point character (.) to indicate that the module name has no extension." */ if( strrchr(libname, '.') == NULL ) strcat(libname, ".dll"); else if( libname[strlen(libname)-1] == '.' ) libname[strlen(libname)-1] = '\0'; dll = DllLoaderContainer::LoadModule(libname, libpath); if (dll) { CLog::Log(LOGDEBUG, "LoadLibrary('%s') returning: %p", libname, (void*)dll); return (HMODULE)dll->GetHModule(); } CLog::Log(LOGERROR, "LoadLibrary('%s') failed", libname); return NULL; }
static void browse_draw_info(struct dir *dr) { struct dir *t; int i; nccreate(11, 60, "Item info"); if(dr->hlnk) { if(info_page == 0) attron(A_REVERSE); ncaddstr(0, 41, "1:Info"); attroff(A_REVERSE); if(info_page == 1) attron(A_REVERSE); ncaddstr(0, 50, "2:Links"); attroff(A_REVERSE); } switch(info_page) { case 0: attron(A_BOLD); ncaddstr(2, 3, "Name:"); ncaddstr(3, 3, "Path:"); ncaddstr(4, 3, "Type:"); ncaddstr(6, 3, " Disk usage:"); ncaddstr(7, 3, "Apparent size:"); attroff(A_BOLD); ncaddstr(2, 9, cropstr(dr->name, 49)); ncaddstr(3, 9, cropstr(getpath(dr->parent), 49)); ncaddstr(4, 9, dr->flags & FF_DIR ? "Directory" : dr->flags & FF_FILE ? "File" : "Other (link, device, socket, ..)"); ncprint(6, 18, "%s (%s B)", formatsize(dr->size), fullsize(dr->size)); ncprint(7, 18, "%s (%s B)", formatsize(dr->asize), fullsize(dr->asize)); break; case 1: for(i=0,t=dr->hlnk; t!=dr; t=t->hlnk,i++) { if(info_start > i) continue; if(i-info_start > 5) break; ncaddstr(2+i-info_start, 3, cropstr(getpath(t), 54)); } if(t!=dr) ncaddstr(8, 25, "-- more --"); break; } ncaddstr(9, 32, "Press i to hide this window"); }
static int luaB_require (lua_State *L) { const char *path; int status = LUA_ERRFILE; /* not found (yet) */ luaL_checkstring(L, 1); lua_settop(L, 1); lua_getglobal(L, REQTAB); if (!lua_istable(L, 2)) return luaL_error(L, "`" REQTAB "' is not a table"); path = getpath(L); lua_pushvalue(L, 1); /* check package's name in book-keeping table */ lua_rawget(L, 2); if (lua_toboolean(L, -1)) /* is it there? */ return 1; /* package is already loaded; return its result */ else { /* must load it */ while (status == LUA_ERRFILE) { lua_settop(L, 3); /* reset stack position */ if ((path = pushnextpath(L, path)) == NULL) break; pushcomposename(L); status = luaL_loadfile(L, lua_tostring(L, -1)); /* try to load it */ } } switch (status) { case 0: { lua_getglobal(L, "_REQUIREDNAME"); /* save previous name */ lua_insert(L, -2); /* put it below function */ lua_pushvalue(L, 1); lua_setglobal(L, "_REQUIREDNAME"); /* set new name */ lua_call(L, 0, 1); /* run loaded module */ lua_insert(L, -2); /* put result below previous name */ lua_setglobal(L, "_REQUIREDNAME"); /* reset to previous name */ if (lua_isnil(L, -1)) { /* no/nil return? */ lua_pushboolean(L, 1); lua_replace(L, -2); /* replace to true */ } lua_pushvalue(L, 1); lua_pushvalue(L, -2); lua_rawset(L, 2); /* mark it as loaded */ return 1; /* return value */ } case LUA_ERRFILE: { /* file not found */ return luaL_error(L, "could not load package `%s' from path `%s'", lua_tostring(L, 1), getpath(L)); } default: { return luaL_error(L, "error loading package `%s' (%s)", lua_tostring(L, 1), lua_tostring(L, -1)); } } }
MESH * getmesh( /* get new mesh data reference */ char *mname, int flags ) { char *pathname; MESH *ms; flags &= IO_LEGAL; for (ms = mlist; ms != NULL; ms = ms->next) if (!strcmp(mname, ms->name)) { ms->nref++; /* increase reference count */ break; } if (ms == NULL) { /* load first time */ ms = (MESH *)calloc(1, sizeof(MESH)); if (ms == NULL) error(SYSTEM, "out of memory in getmesh"); ms->name = savestr(mname); ms->nref = 1; ms->mcube.cutree = EMPTY; ms->next = mlist; mlist = ms; } if ((pathname = getpath(mname, getrlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find mesh file \"%s\"", mname); error(USER, errmsg); } flags &= ~ms->ldflags; if (flags) readmesh(ms, pathname, flags); return(ms); }
pubyte getpath( pubyte filename ) { uint i = 0, last = 0, dot = 0; while ( filename[i] ) { if ( filename[i] == '\\' ) last = i; if ( filename[i] == '.' ) dot = i; i++; } if ( !last ) { ubyte temp[512]; GetFullPathName( filename, 512, temp, NULL ); mem_copyuntilzero( filename, temp ); return getpath( filename ); } filename[dot] = 0; filename[last] = 0; return filename + last + 1; }
void saveview( /* save view to rad file */ char *s ) { char view[64]; char *fname; FILE *fp; if (*atos(view, sizeof(view), s)) { if (isint(view)) { error(COMMAND, "cannot write view by number"); return; } s = sskip(s); } if (nextword(rifname, sizeof(rifname), s) == NULL && !rifname[0]) { error(COMMAND, "no previous rad file"); return; } if ((fname = getpath(rifname, NULL, 0)) == NULL || (fp = fopen(fname, "a")) == NULL) { sprintf(errmsg, "cannot open \"%s\"", rifname); error(COMMAND, errmsg); return; } fputs("view= ", fp); fputs(view, fp); fprintview(&ourview, fp); putc('\n', fp); fclose(fp); }
int myclianttest::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: readyRead(); break; case 1: bytesWritten((*reinterpret_cast< qint64(*)>(_a[1]))); break; case 2: disconnected(); break; case 3: list((*reinterpret_cast< QString(*)>(_a[1]))); break; case 4: connected(); break; case 5: test(); break; case 6: mycomputer((*reinterpret_cast< QString(*)>(_a[1]))); break; case 7: doubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 8: doubleClickedServer((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 9: setpath((*reinterpret_cast< QString(*)>(_a[1]))); break; case 10: getpath(); break; case 11: servercomputer((*reinterpret_cast< QByteArray(*)>(_a[1]))); break; case 12: serverfiledown((*reinterpret_cast< QByteArray(*)>(_a[1]))); break; case 13: getserverpath(); break; case 14: download(); break; case 15: Serverclicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 16: gotomotherpath(); break; case 17: gotoservermotherpath(); break; default: ; } _id -= 18; } return _id; }
int main(int argc, char **argv) { getpath(); }
void katuyou(FILE *fp_out) { FILE *fp; char cur_path[FILENAME_MAX]; char juman_path[FILENAME_MAX]; char katuyoufile_path[FILENAME_MAX]; getpath(cur_path, juman_path); while (1) { if ((fp = pathfopen(KATUYOUFILE, "r", "", katuyoufile_path)) != NULL) break; if ((fp = pathfopen(KATUYOUFILE, "r", cur_path, katuyoufile_path)) != NULL) break; if ((fp = pathfopen(KATUYOUFILE, "r", juman_path, katuyoufile_path)) != NULL) break; if ((fp = pathfopen(KATUYOUFILE, "r", "../dic/", katuyoufile_path)) /* for compilation */ != NULL) break; error(OpenError, "can't open", katuyoufile_path, ".", EOA); } if (fp_out != NULL) { print_current_time(fp_out); fprintf(fp_out, "%s parsing... ", katuyoufile_path); } initialize_type_form(); read_type_form(fp); if (fp_out != NULL) fputs("done.\n\n", fp_out); fclose(fp); }
ATF_TC_BODY(link_count, tc) { struct stat sa, sb; int fd; (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); pathl = getpath(); fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(pathl != NULL); ATF_REQUIRE(stat(path, &sa) == 0); ATF_REQUIRE(link(path, pathl) == 0); ATF_REQUIRE(stat(path, &sb) == 0); if (sa.st_nlink != sb.st_nlink - 1) atf_tc_fail("incorrect link(2) count"); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); ATF_REQUIRE(unlink(pathl) == 0); }
ATF_TC_BODY(link_stat, tc) { struct stat sa, sb; int fd; (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); pathl = getpath(); fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(pathl != NULL); ATF_REQUIRE(link(path, pathl) == 0); ATF_REQUIRE(stat(path, &sa) == 0); ATF_REQUIRE(lstat(pathl, &sb) == 0); if (sa.st_uid != sb.st_uid) atf_tc_fail("unequal UIDs"); if (sa.st_mode != sb.st_mode) atf_tc_fail("unequal modes"); if (sa.st_ino != sb.st_ino) atf_tc_fail("unequal inodes"); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); ATF_REQUIRE(unlink(pathl) == 0); }
/* Execute wrapBSDF command (may never return) */ static int wrap_up(void) { char buf[256]; char *compath = getpath((char *)wrapBSDF[0], getenv("PATH"), X_OK); if (compath == NULL) { fprintf(stderr, "%s: cannot locate %s\n", progname, wrapBSDF[0]); return(1); } if (bsdf_manuf[0]) { add_wbsdf("-f", 1); strcpy(buf, "m="); strcpy(buf+2, bsdf_manuf); add_wbsdf(buf, 0); } if (bsdf_name[0]) { add_wbsdf("-f", 1); strcpy(buf, "n="); strcpy(buf+2, bsdf_name); add_wbsdf(buf, 0); } execv(compath, wrapBSDF); /* successful call never returns */ perror(compath); return(1); }
void lastview( /* return to a previous view */ char *s ) { char buf[128]; char *fname; int success; VIEW nv; /* get parameters from a file */ if (nextword(buf, sizeof(buf), s) != NULL) { nv = stdview; if ((fname = getpath(buf, "", R_OK)) == NULL || (success = viewfile(fname, &nv, NULL)) == -1) { sprintf(errmsg, "cannot open \"%s\"", buf); error(COMMAND, errmsg); return; } if (!success) error(COMMAND, "wrong file format"); else newview(&nv); return; } if (oldview.type == 0) { /* no old view! */ error(COMMAND, "no previous view"); return; } nv = ourview; ourview = oldview; oldview = nv; newimage(NULL); }
MESHINST * getmeshinst( /* create mesh instance */ OBJREC *o, int flags ) { MESHINST *ins; flags &= IO_LEGAL; if ((ins = (MESHINST *)o->os) == NULL) { if ((ins = (MESHINST *)malloc(sizeof(MESHINST))) == NULL) error(SYSTEM, "out of memory in getmeshinst"); if (o->oargs.nsargs < 1) objerror(o, USER, "bad # of arguments"); if (fullxf(&ins->x, o->oargs.nsargs-1, o->oargs.sarg+1) != o->oargs.nsargs-1) objerror(o, USER, "bad transform"); if (ins->x.f.sca < 0.0) { ins->x.f.sca = -ins->x.f.sca; ins->x.b.sca = -ins->x.b.sca; } ins->msh = NULL; o->os = (char *)ins; } if (ins->msh == NULL) ins->msh = getmesh(o->oargs.sarg[0], flags); else if ((flags &= ~ins->msh->ldflags)) readmesh(ins->msh, getpath(o->oargs.sarg[0], getrlibpath(), R_OK), flags); return(ins); }
void browse_draw() { struct dir *t; char fmtsize[9], *tmp; int selected, i; erase(); t = dirlist_get(0); /* top line - basic info */ attron(A_REVERSE); mvhline(0, 0, ' ', wincols); mvhline(winrows-1, 0, ' ', wincols); mvprintw(0,0,"%s %s ~ Use the arrow keys to navigate, press ? for help", PACKAGE_NAME, PACKAGE_VERSION); if(read_only) mvaddstr(0, wincols-11, "[read-only]"); attroff(A_REVERSE); /* second line - the path */ mvhline(1, 0, '-', wincols); if(t) { mvaddch(1, 3, ' '); tmp = getpath(t->parent); mvaddstr(1, 4, cropstr(tmp, wincols-8)); mvaddch(1, 4+((int)strlen(tmp) > wincols-8 ? wincols-8 : (int)strlen(tmp)), ' '); } /* bottom line - stats */ attron(A_REVERSE); if(t) { strcpy(fmtsize, formatsize(t->parent->size)); mvprintw(winrows-1, 0, " Total disk usage: %s Apparent size: %s Items: %d", fmtsize, formatsize(t->parent->asize), t->parent->items); } else mvaddstr(winrows-1, 0, " No items to display."); attroff(A_REVERSE); /* nothing to display? stop here. */ if(!t) return; /* get start position */ t = dirlist_top(0); /* print the list to the screen */ for(i=0; t && i<winrows-3; t=dirlist_next(t),i++) { browse_draw_item(t, 2+i); /* save the selected row number for later */ if(t->flags & FF_BSEL) selected = i; } /* draw information window */ t = dirlist_get(0); if(info_show && t != dirlist_parent) browse_draw_info(t); /* move cursor to selected row for accessibility */ move(selected+2, 0); }
void writepict( /* write the picture to a file */ char *s ) { static char buf[128]; char *fname; FILE *fp; COLR *scanline; int y; /* XXX relies on words.c 2.11 behavior */ if (nextword(buf, sizeof(buf), s) == NULL && !buf[0]) { error(COMMAND, "no file"); return; } if ((fname = getpath(buf, NULL, 0)) == NULL || (fp = fopen(fname, "w")) == NULL) { sprintf(errmsg, "cannot open \"%s\"", buf); error(COMMAND, errmsg); return; } SET_FILE_BINARY(fp); (*dev->comout)("writing \""); (*dev->comout)(fname); (*dev->comout)("\"...\n"); /* write header */ newheader("RADIANCE", fp); fputs(progname, fp); fprintview(&ourview, fp); if (octname != NULL) fprintf(fp, " %s\n", octname); else putc('\n', fp); fprintf(fp, "SOFTWARE= %s\n", VersionID); fputnow(fp); if (exposure != 1.0) fputexpos(exposure, fp); if (dev->pixaspect != 1.0) fputaspect(dev->pixaspect, fp); fputformat(COLRFMT, fp); putc('\n', fp); fprtresolu(hresolu, vresolu, fp); scanline = (COLR *)malloc(hresolu*sizeof(COLR)); if (scanline == NULL) { error(COMMAND, "not enough memory!"); fclose(fp); unlink(fname); return; } for (y = vresolu-1; y >= 0; y--) { getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu); if (fwritecolrs(scanline, hresolu, fp) < 0) break; } free((void *)scanline); if (fclose(fp) < 0) error(COMMAND, "write error"); }
void getpath(int start,struct searchd_nodent *cur) { if(cur->pare!=-1){ getpath(start,list+start+cur->pare); strcat(buf,"/"); strcat(buf2,"/"); strcat(buf,cur->name); strcat(buf2,cur->ori_name); } }
int tt0137_start(struct global_struct *gbp) { if((getpath(gbp)) == -1) /* Get the current working path */ return(-1); GetInf(gbp); /* Read info from INF file */ return(0); }
int fill_entry_struct(struct Entry *entry, const struct Rc *rc, const struct Options *opt) { unsigned int i; assert(entry); assert(rc); assert(opt); /* * Get information about the environment; hostname, current directory, * login name and tty. * * Fixme: Add check so this and the session info thing are run only * once. Only has some effect if creating many UUIDs. */ entry->host = get_hostname(rc); if (!entry->host) { myerror("fill_entry_struct(): Cannot get hostname"); return EXIT_FAILURE; } if (!valid_hostname(entry->host)) { myerror("fill_entry_struct(): Got invalid hostname: \"%s\"", entry->host); return EXIT_FAILURE; } entry->cwd = getpath(); entry->user = get_username(); entry->tty = get_tty(); /* * Store tags and comment in entry. */ for (i = 0; i < MAX_TAGS && opt->tag[i]; i++) if (store_tag(entry, opt->tag[i]) == EXIT_FAILURE) return EXIT_FAILURE; if (opt->comment) { entry->txt = process_comment_option(opt->comment); if (!entry->txt) return EXIT_FAILURE; } /* * Store session information from the environment variable. */ if (get_sess_info(entry) == EXIT_FAILURE) { free(entry->txt); return EXIT_FAILURE; } return EXIT_SUCCESS; }
extern struct driver * comm_init( /* set up and execute driver */ char *dname, char *id ) { char *dvcname; int p1[2], p2[2]; char pin[16], pout[16]; /* find driver program */ if ((dvcname = getpath(dname, DEVPATH, X_OK)) == NULL) { eputs(dname); eputs(": not found\n"); return(NULL); } #ifdef RHAS_FORK_EXEC /* open communication pipes */ if (pipe(p1) == -1 || pipe(p2) == -1) goto syserr; if ((devchild = fork()) == 0) { /* fork driver process */ close(p1[1]); close(p2[0]); sprintf(pin, "%d", p1[0]); sprintf(pout, "%d", p2[1]); execl(dvcname, dname, pin, pout, id, NULL); perror(dvcname); _exit(127); } if (devchild == -1) goto syserr; close(p1[0]); close(p2[1]); /* * Close write stream on exec to avoid multiprocessing deadlock. * No use in read stream without it, so set flag there as well. */ fcntl(p1[1], F_SETFD, FD_CLOEXEC); fcntl(p2[0], F_SETFD, FD_CLOEXEC); if ((devout = fdopen(p1[1], "w")) == NULL) goto syserr; if ((devin = fdopen(p2[0], "r")) == NULL) goto syserr; return(final_connect()); /* verify initialization */ syserr: perror(dname); return(NULL); #else /* ! RHAS_FORK_EXEC */ eputs(dname); eputs(": no fork/exec\n"); return(NULL); #endif /* ! RHAS_FORK_EXEC */ }
int ft0006_start(struct global_struct *gbp) { if((getpath(gbp)) == -1) return(-1); GetInf(gbp); return(0); }
void printlink(char *name, char *path) { char *buf; buf = ft_strnew(512); ft_putstr(" -> "); ft_bzero(buf, 512); readlink(getpath(path, name), buf, 512); ft_putstr(buf); free(buf); }
int test_dot(void) { errorf("\n"); /* prints the function name */ File *file = newfile("", "."); assert(strcmp(getname(file), ".") == 0); assert(strcmp(getpath(file), ".") == 0); char *dir = getdirname(file); assert(strcmp(dir, ".") == 0); free(dir); free(file); return 0; }
void cute(){ getpath(); //for (int i=1;i<=sink;i++) printf("%d ",prev[i]); //printf("\n"); int v=sink; while (v!=source){ --dat[pree[v]]; ++dat[pree[v]^1]; ans+=cost[pree[v]]; v=prev[v]; } }
int deleteblock(u64_t blocknum) { getpath(blocknum); FILE *block; if ((block = fopen(path, "rb")) == NULL) { printf("block not exist!"); } else { fclose(block); remove(path); } deletelist(blocknum); return 0; }
int open_process(SUBPROC *proc, char *av[]) { char *cmdpath; char *cmdstr; proc->running = 0; if (av == NULL) { return -1; } cmdpath = getpath(av[0], getenv("PATH"), X_OK); cmdstr = quoted_cmdline(cmdpath, av+1); if (cmdstr == NULL) { return 0; } return start_process(proc, cmdstr); }
/* Load a BSDF XML file and produce a corresponding Radiance object */ static int cvtBSDF(char *fname) { int retOK; SDData myBSDF; char *pname, *fnbeg; /* find and load the XML file */ retOK = strlen(fname); if (retOK < 5 || strcmp(fname+retOK-4, ".xml")) { fprintf(stderr, "%s: input does not end in '.xml'\n", fname); return(0); } pname = getpath(fname, getrlibpath(), R_OK); if (pname == NULL) { fprintf(stderr, "%s: cannot find BSDF file\n", fname); return(0); } fnbeg = strrchr(fname, DIRSEP); if (fnbeg != NULL) /* eliminate directory */ fname = fnbeg+1; SDclearBSDF(&myBSDF, fname); if (SDreportError(SDloadFile(&myBSDF, pname), stderr)) return(0); retOK = (myBSDF.dim[0] > FTINY) & (myBSDF.dim[1] > FTINY); if (!retOK) { fprintf(stderr, "%s: zero width or height\n", fname); } else { if (!do_stdout) { char rname[SDnameLn+4]; strcpy(rname, myBSDF.name); strcat(rname, ".rad"); retOK = (freopen(rname, "w", stdout) != NULL); } if (retOK) { if (myBSDF.matn[0] && myBSDF.makr[0]) printf("# Material '%s' by '%s'\n\n", myBSDF.matn, myBSDF.makr); if (myBSDF.mgf == NULL) { faceBSDF(&myBSDF, .0); } else { faceBSDF(&myBSDF, myBSDF.dim[2]); if (myBSDF.rb != NULL) faceBSDF(&myBSDF, -myBSDF.dim[2]); retOK = geomBSDF(&myBSDF); } } } SDfreeBSDF(&myBSDF); /* clean up and return */ return(retOK); }
int createblock(u64_t blocknum) { getpath(blocknum); int i; FILE *block1; block1 = fopen(path, "wb"); char buf[1024]; //memset(buf, "0", 1024); strcpy(buf, "567890"); for (i = 0; i < 1024 * 16; i++) { fwrite(buf, 1024, 1, block1); } fclose(block1); addlist(blocknum); return 0; }
int test_bare_file(void) { errorf("\n"); /* prints the function name */ File *file = newfile(".", "buf.c"); assert(strcmp(getname(file), "buf.c") == 0); assert(strcmp(getpath(file), "./buf.c") == 0); char *dir = getdirname(file); assert(strcmp(dir, ".") == 0); free(dir); char *base = getbasename(file); assert(strcmp(base, "buf.c") == 0); free(base); free(file); return 0; }
int test_relative_file(void) { errorf("\n"); /* prints the function name */ File *file = newfile(".", "../tmp/foo"); assert(strcmp(getname(file), "../tmp/foo") == 0); assert(strcmp(getpath(file), "./../tmp/foo") == 0); char *dir = getdirname(file); assert(strcmp(dir, "./../tmp") == 0); free(dir); char *base = getbasename(file); assert(strcmp(base, "foo") == 0); free(base); free(file); return 0; }