Exemple #1
0
BOOL PutHash( LPCTSTR lpszFile, LPOPTIONS lpOpt )
{
	DWORD w;
	LPCTSTR lpszFormat;

	if( lpOpt->DispFilename ){
		lpszFormat = _T( "%3!s!(%4!s!) : %1!s!-%2!8.8X!.pf\n" );
	}else{
		if( lpOpt->HashXp && lpOpt->HashVista ){
			lpszFormat = _T( "(%4!s!) : %1!s!-%2!8.8X!.pf\n" );
		}else{
			lpszFormat = _T( "%1!s!-%2!8.8X!.pf\n" );
		}
	}

	if( lpOpt->HashVista ){
		w = HashVista( lpszFile );
		my_printf( hStdout, lpszFormat, Basename( lpszFile ), w, lpszFile, _T("Vista") );
	}
	if( lpOpt->HashXp ){
		w = HashXp( lpszFile );
		my_printf( hStdout, lpszFormat, Basename( lpszFile ), w, lpszFile, _T("XP") );
	}
	return TRUE;


}
Exemple #2
0
/**
 * @brief
 */
static cm_material_t *Cm_LoadBspMaterials(const char *name) {

    char base[MAX_QPATH];
    StripExtension(Basename(name), base);

    return Cm_LoadMaterials(va("materials/%s.mat", base), NULL);
}
Exemple #3
0
bool COption::init(int argc, char** argv)
{
    if(m_bInit)
    {
        return true;
    }
    m_optNum = sizeof(OptTab)/sizeof(OptTab[0]);
    if(!initOption())
    {
        return false;
    }
    
    //获取程序名称
    m_myName = Basename(argv[0]);
    
    //获取命令行选项
    int oc = -1;
    char optString[sizeof(OptTab)/sizeof(OptTab[0]) * 2] = {0};
    makeOptString(optString);

    //解析命令行
    while((oc = getopt(argc, argv, optString)) != -1)
    {
        if(Unknown_key == oc || Usage_key == oc)
        {
            usage();
            return false;
        }

        setOption(oc, optarg);
    }

    return true;
}
Exemple #4
0
static
VOID
ShowUsage(
    PCSTR pszProgramName,
    BOOLEAN bFull
    )
{
    printf(
        "Usage: %s [ --<object type> ] [ <flags> ] [ --provider name ]\n",
        Basename(pszProgramName));
    
    if (bFull)
    {
        printf(
            "\n"
            "Object type options:\n"
            "    --user                  Return only user objects\n"
            "    --group                 Return only group objects\n"
            "\n"
            "Query flags:\n"
            "     --nss                  Omit data not necessary for NSS layer\n"
            "\n"
            "Other options:\n"
            "     --domain name          Restrict enumeration to the specified NetBIOS domain\n"
            "     --provider name        Direct request to provider with the specified name\n"
            "\n");
    }
}
Exemple #5
0
/*
 * Cl_LoadLocations
 *
 * Parse a .loc file for the current level.
 */
void Cl_LoadLocations(void) {
	const char *c;
	char file_name[MAX_QPATH];
	FILE *f;
	int i;

	Cl_ClearLocations(); // clear any resident locations
	i = 0;

	// load the locations file
	c = Basename(cl.config_strings[CS_MODELS + 1]);
	snprintf(file_name, sizeof(file_name), "locations/%s", c);
	strcpy(file_name + strlen(file_name) - 3, "loc");

	if (Fs_OpenFile(file_name, &f, FILE_READ) == -1) {
		Com_Debug("Couldn't load %s\n", file_name);
		return;
	}

	while (i < MAX_LOCATIONS) {

		const int err = fscanf(f, "%f %f %f %[^\n]", &locations[i].loc[0],
				&locations[i].loc[1], &locations[i].loc[2], locations[i].desc);

		num_locations = i;
		if (err == EOF)
			break;
		i++;
	}

	Cl_LoadProgress(100);

	Com_Print("Loaded %i locations.\n", num_locations);
	Fs_CloseFile(f);
}
/* -------------------------------------------------------------
 * do_stat: print all important inode info for the path INODE 
 *      (1) get INODE of path into a minode[] table 
 *      (2) print all important info 
 * 
 * Note: This is the lazy way. KC's recommended way utilizes
 * the stat struct 
 --------------------------------------------------------------*/
void do_stat(char* path)
{
    MINODE* dir; 
    char timebuf[256]; 
    int ino; 
    int dev = running->cwd->dev; 
    
    //(1) get INODE of path into a minode[table]
    ino = getino(&dev, path);   // get ino 
    dir = iget(dev, ino);       // get MINODE* 
    
    if(dir == NULL)
    {
        printf("Error: unable to stat %s\n", path); 
        return; 
    }
    
    // Copy dir's modified time into timebuf
    ctime_r(&dir->INODE.i_mtime, timebuf); 
    timebuf[24] = 0;    // add NULL terminator 
    
    
    printf("-------------------------------------------------------\n"); 
    printf("file: %s\n", Basename(path)); 
    printf("dev: %d\t\tinode number: %i\tmode:%3x\n", dir->dev, dir->ino, dir->INODE.i_mode); 
    printf("uid: %i\tgid: %i\tlink count: %d\n", running->uid, running->gid, dir->INODE.i_links_count); 
    printf("size: %d\t\t%5s\n", dir->INODE.i_size, timebuf); 
    printf("-------------------------------------------------------\n"); 
    
    iput(dir); 
    
    
}
Exemple #7
0
bool RageSound::Load( CString sSoundFilePath, bool bPrecache )
{
	LOG->Trace( "RageSound::LoadSound( '%s', %d )", sSoundFilePath.c_str(), bPrecache );

	CString error;
	SoundReader *pSound = SoundReader_FileReader::OpenFile( sSoundFilePath, error );
	if( pSound == NULL )
	{
		LOG->Warn( "RageSound::Load: error opening sound \"%s\": %s",
			sSoundFilePath.c_str(), error.c_str() );

		pSound = new RageSoundReader_Silence;
	}

	LoadSoundReader( pSound );

	/* Try to precache.  Do this after calling LoadSoundReader() to put the
	 * sound in this->m_pSource, so we preload after resampling. */
	if( bPrecache )
		RageSoundReader_Preload::PreloadSound( m_pSource );

	m_sFilePath = sSoundFilePath;

	m_Mutex.SetName( ssprintf("RageSound (%s)", Basename(sSoundFilePath).c_str() ) );

	return true;
}
Exemple #8
0
const char* FileInfo::tail()
{
	const char* name = Basename();
	const char* pt =  strrchr(name, '.');

	return (pt == NULL ? "" : pt);
}
void ScreenTestSound::UpdateText(int n)
{
	RString fn = Basename( s[n].s.GetLoadedFilePath() );

	vector<RageSound *> &snds = m_sSoundCopies[n];

	RString pos;
	for(unsigned p = 0; p < snds.size(); ++p)
	{
		if(p) pos += ", ";
		pos += ssprintf("%.3f", snds[p]->GetPositionSeconds());
	}

	s[n].txt.SetText(ssprintf(
		"%i: %s\n"
		"%s\n"
		"%s\n"
		"(%s)\n"
		"%s",
		n+1, fn.c_str(),
		s[n].s.IsPlaying()? "Playing":"Stopped",
		s[n].s.GetParams().StopMode == RageSoundParams::M_STOP?
			"Stop when finished":
		s[n].s.GetParams().StopMode == RageSoundParams::M_CONTINUE?
			"Continue until stopped":
			"Loop",
		pos.size()? pos.c_str(): "none playing",
		selected == n? "^^^^^^":""
		));
}
static RString MakeTempFilename( const RString &sPath )
{
	/* "Foo/bar/baz" -> "Foo/bar/new.baz.new".  Both prepend and append: we don't
	 * want a wildcard search for the filename to match (foo.txt.new matches foo.txt*),
	 * and we don't want to have the same extension (so "new.foo.sm" doesn't show up
	 * in *.sm). */
	return Dirname(sPath) + "new." + Basename(sPath) + ".new";
}
Exemple #11
0
/*
 * grpck - verify group file integrity
 */
int main (int argc, char **argv)
{
	int errors = 0;
	bool changed = false;

	/*
	 * Get my name so that I can use it to report errors.
	 */
	Prog = Basename (argv[0]);

	(void) setlocale (LC_ALL, "");
	(void) bindtextdomain (PACKAGE, LOCALEDIR);
	(void) textdomain (PACKAGE);

	process_root_flag ("-R", argc, argv);

	OPENLOG ("grpck");

	/* Parse the command line arguments */
	process_flags (argc, argv);

	open_files ();

	if (sort_mode) {
		gr_sort ();
#ifdef	SHADOWGRP
		if (is_shadow) {
			sgr_sort ();
		}
		changed = true;
#endif
	} else {
		check_grp_file (&errors, &changed);
#ifdef	SHADOWGRP
		if (is_shadow) {
			check_sgr_file (&errors, &changed);
		}
#endif
	}

	/* Commit the change in the database if needed */
	close_files (changed);

	nscd_flush_cache ("group");

	/*
	 * Tell the user what we did and exit.
	 */
	if (0 != errors) {
		if (changed) {
			printf (_("%s: the files have been updated\n"), Prog);
		} else {
			printf (_("%s: no changes\n"), Prog);
		}
	}

	return ((0 != errors) ? E_BAD_ENTRY : E_OKAY);
}
Exemple #12
0
/**
 * return file root name (ie without suffix)
 */
const char* FileInfo::rootname()
{
	_rootname = Basename();
	unsigned long pos = _rootname.rfind(".");
	if ( pos != string::npos )
		_rootname.erase(pos,  string::npos);

	return _rootname.c_str();
}
Exemple #13
0
/*
 * main - groupadd command
 */
int main (int argc, char **argv)
{
	/*
	 * Get my name so that I can use it to report errors.
	 */
	Prog = Basename (argv[0]);

	(void) setlocale (LC_ALL, "");
	(void) bindtextdomain (PACKAGE, LOCALEDIR);
	(void) textdomain (PACKAGE);

	process_root_flag ("-R", argc, argv);
	prefix = process_prefix_flag ("-P", argc, argv);

	OPENLOG ("groupadd");
#ifdef WITH_AUDIT
	audit_help_open ();
#endif

	if (atexit (do_cleanups) != 0) {
		fprintf (stderr,
		         _("%s: Cannot setup cleanup service.\n"),
		         Prog);
		exit (1);
	}

	/*
	 * Parse the command line options.
	 */
	process_flags (argc, argv);

	check_perms ();

#ifdef SHADOWGRP
	is_shadow_grp = sgr_file_present ();
#endif

	/*
	 * Do the hard stuff - open the files, create the group entries,
	 * then close and update the files.
	 */
	open_files ();

	if (!gflg) {
		if (find_new_gid (rflg, &group_id, NULL) < 0) {
			exit (E_GID_IN_USE);
		}
	}

	grp_update ();
	close_files ();

	nscd_flush_cache ("group");

	return E_SUCCESS;
}
Exemple #14
0
/*!
*
*/
int
main(int argc, char** argv)
{
  char *progname = argv[0];

  glutInit(&argc, argv);

  for(++argv; --argc > 0; ++argv)
  {
    if( strcmp(*argv, "-help") ==  0 || strcmp(*argv, "--help") == 0 )
    {
      fputs("View a 3DS model file using OpenGL.\n", stderr);
      fputs("Usage: 3dsplayer [-nodb|-aa|-flush] <filename>\n", stderr);
#ifndef USE_SDL
      fputs("Texture rendering is not available; install SDL_image and recompile.\n", stderr);
#endif
      exit(0);
    }
    else if( strcmp(*argv, "-nodb") == 0 )
      dbuf = 0;
    else if( strcmp(*argv, "-aa") == 0 )
      anti_alias = 1;
    else if( strcmp(*argv, "-flush") == 0 )
      flush = 1;
    else {
      filepath = *argv;
      decompose_datapath(filepath);
    }
  }

  if (filepath == NULL) {
    fputs("3dsplayer: Error: No 3DS file specified\n", stderr);
    exit(1);
  }

  glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | (dbuf ? GLUT_DOUBLE:0) );
  glutInitWindowSize(500, 500);
  glutInitWindowPosition(100, 100);
  glutCreateWindow(filepath != NULL ? Basename(filepath) : progname);

  init();
  create_icons();
  load_model();

  build_menu();
  glutAttachMenu(2);

  glutDisplayFunc(display);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(keyboard);
  glutMouseFunc(mouse_cb);
  glutMotionFunc(drag_cb);
  glutTimerFunc(10, timer_cb, 0);
  glutMainLoop();
  return(0);
}
static string GetDumpLocalID()
{
  string localId = Basename(gReporterDumpFile);
  string::size_type dot = localId.rfind('.');

  if (dot == string::npos)
    return "";

  return localId.substr(0, dot);
}
void DataFlowTrace::ReadCoverage(const std::string &DirPath) {
  Vector<SizedFile> Files;
  GetSizedFilesFromDir(DirPath, &Files);
  for (auto &SF : Files) {
    auto Name = Basename(SF.File);
    if (Name == kFunctionsTxt) continue;
    std::ifstream IF(SF.File);
    Coverage.AppendCoverage(IF);
  }
}
void DirectFilenameDB::CacheFile( const RString &sPath )
{
	CHECKPOINT_M( root+sPath );
	RString sDir = Dirname( sPath );
	FileSet *pFileSet = GetFileSet( sDir, false );
	if( pFileSet == NULL )
	{
		// This directory isn't cached so do nothing.
		m_Mutex.Unlock(); // Locked by GetFileSet()
		return;
	}
	while( !pFileSet->m_bFilled )
		m_Mutex.Wait();
		
#if defined(WIN32)
	// There is almost surely a better way to do this
	WIN32_FIND_DATA fd;
	HANDLE hFind = DoFindFirstFile( root+sPath, &fd );
	if( hFind == INVALID_HANDLE_VALUE )
	{
		m_Mutex.Unlock(); // Locked by GetFileSet()
		return;
	}
	File f( fd.cFileName );
	f.dir = !!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
	f.size = fd.nFileSizeLow;
	f.hash = fd.ftLastWriteTime.dwLowDateTime;
	
	pFileSet->files.insert( f );
	FindClose( hFind );
#else
	File f( Basename(sPath) );
	
	struct stat st;
	if( DoStat(root+sPath, &st) == -1 )
	{
		int iError = errno;
		/* If it's a broken symlink, ignore it.  Otherwise, warn. */
		/* Huh? */
		WARN( ssprintf("File '%s' is gone! (%s)",
			       sPath.c_str(), strerror(iError)) );
	}
	else
	{
		f.dir = (st.st_mode & S_IFDIR);
		f.size = (int)st.st_size;
		f.hash = st.st_mtime;
	}
	
	pFileSet->files.insert(f);
#endif
	m_Mutex.Unlock(); // Locked by GetFileSet()	
}
Exemple #18
0
const char* FileInfo::realpath()
{

	char* pt = strdup( _path.c_str());
    string dir = ::dirname(pt);
	free(pt);

	_realpath = _path;

	if ( dir[0] == '~' )
	{
//		const char* pt = getenv("HOME");
		const gchar* pt = g_get_home_dir() ;
		if ( pt != NULL )
			dir = pt + dir.substr(1);
	}
	else if ( dir[0] == '$' )
	{
		char varname[80];
		const char* pt;
		int i;
		for ( i=0, pt = dir.c_str()+1;
			*pt && *pt != ')' && strncmp(pt,_path_delim,1) ; ++pt )
			if ( *pt == '(' ) continue;
			else varname[i++] = *pt;
		varname[i] = 0;
		if ( *pt == ')' ) ++pt;

		if ( varname[0] ) {
			const char* pt2 = getenv(varname);
			if ( pt2 != NULL ) {
				dir = string(pt2) + string(pt);
			} else
				Log::err() << "Error in FileInfo::realpath : undefined environment variable " << varname << endl;
		}
	}
	else if ( dir[0] == '.' )
	{
  		char resolved[MAXPATHLEN];
		char current[MAXPATHLEN];
		if ( getcwd(current, sizeof(current)) == NULL )
			return "";  // rep courant indefini
		if ( chdir(dir.c_str()) != 0 )
			return ""; // path invalide
		getcwd(resolved, sizeof(resolved));
		chdir (current);
		dir=resolved;
	}

	_realpath = FileInfo(dir).join(Basename());

	return _realpath.c_str();
}
Exemple #19
0
void BackgroundUtil::GetGlobalBGAnimations( const Song *pSong, const RString &sMatch, vector<RString> &vsPathsOut, vector<RString> &vsNamesOut )
{
	vsPathsOut.clear();
	GetDirListing( BG_ANIMS_DIR+sMatch+"*", vsPathsOut, true, true );
	GetDirListing( BG_ANIMS_DIR+sMatch+"*.xml", vsPathsOut, false, true );

	vsNamesOut.clear();
	FOREACH_CONST( RString, vsPathsOut, s )
		vsNamesOut.push_back( Basename(*s) );

	StripCvsAndSvn( vsPathsOut, vsNamesOut );
}
static bool MoveCrashData(const string& toDir,
                          string& dumpfile,
                          string& extrafile,
                          string& memoryfile)
{
  if (!UIEnsurePathExists(toDir)) {
    UIError(gStrings[ST_ERROR_CREATEDUMPDIR]);
    return false;
  }

  string newDump = toDir + UI_DIR_SEPARATOR + Basename(dumpfile);
  string newExtra = toDir + UI_DIR_SEPARATOR + Basename(extrafile);
  string newMemory = toDir + UI_DIR_SEPARATOR + Basename(memoryfile);

  if (!UIMoveFile(dumpfile, newDump)) {
    UIError(gStrings[ST_ERROR_DUMPFILEMOVE]);
    return false;
  }

  if (!UIMoveFile(extrafile, newExtra)) {
    UIError(gStrings[ST_ERROR_EXTRAFILEMOVE]);
    return false;
  }

  if (!memoryfile.empty()) {
    // Ignore errors from moving the memory file
    if (!UIMoveFile(memoryfile, newMemory)) {
      UIDeleteFile(memoryfile);
      newMemory.erase();
    }
    memoryfile = newMemory;
  }

  dumpfile = newDump;
  extrafile = newExtra;

  return true;
}
/* -------------------------------------------------------
 * make_dir: 
 *      must understand perfectly!!!
 * 
 *      Takes a pathname as parameter 
 * 
 *      (1) set the device 
 *      (2) get parent MINODE by using dirname with 
 *              getino 
 *          Load MINODE using iget 
 *      (3) call my_mkdir(MINODE* parent, char* name)
 * 
 --------------------------------------------------------*/
void make_dir(char* path)
{
    MINODE* pip;                // parent MINODE* 
    int dev, pino;              // device, parent ino 
    
    // parent = path to parent directory, child = basename 
    char* parent, *child;        
    
    // (1) Set device according to relative or absolute path 
    if(path[0] == '/')
        dev = root->dev; 
    else 
        dev = running->cwd->dev; 
    
    // (2) Separate path into dirname and basename 
    parent = strdup(Dirname(path));     // make copies 
    child = strdup(Basename(path)); 
    
    // Debug print 
    //printf("parent: %s\n", parent);
    //printf("child: %s\n", child);
    
    // (3) get in memory MINODE of parent directory 
    pino = getino(&dev, parent); // First, get parent ino 
    pip = iget(dev, pino); // Then use it to load INODE into minode[] table
    
    
    // (4) Error checking on found MINODE
    if(pip == NULL)                     // (4.1) ensure the MINODE was found 
    {
        printf("Error: unable to locate %s\n", parent); 
    }
    else if(!isdir(pip))                // (4.2) is DIR 
    {
        printf("Error: %s is not a directory\n", parent);
    }
    else if(search(pip, child) != 0)    // (4.3) child does not already exist    
    {
        // the child was already found 
        printf("Error: %s already exists in %s\n", child, parent); 
    }
    // (5) We've verified that parent path exists, is a directory 
        // and child does not exist in it, so add to it  
    else
        my_mkdir(pip,child); 
    
    // No matter what, dont forget to write back! 
    // Release parent from minode[] table and write back to disk 
    iput(pip);
}
Exemple #22
0
int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
{
	char arg0[1024];
	int err;

	if (file == (char *) 0) {
		errno = EINVAL;
		return errno;
	}

	/*
	 * The argv[0]'th entry is usually the path name, but
	 * for various reasons the invoker may want to override
	 * that.  So, we determine the 0'th entry only if they
	 * don't want to tell us what it is themselves.
	 */
	if (arg == (char *) 0) {
		(void) snprintf (arg0, sizeof arg0, "-%s", Basename ((char *) file));
		arg0[sizeof arg0 - 1] = '\0';
		arg = arg0;
	}

	/*
	 * First we try the direct approach.  The system should be
	 * able to figure out what we are up to without too much
	 * grief.
	 */
	(void) execle (file, arg, (char *) 0, envp);
	err = errno;

	if (access (file, R_OK|X_OK) == 0) {
		/*
		 * Assume this is a shell script (with no shebang).
		 * Interpret it with /bin/sh
		 */
		(void) execle (SHELL, "sh", "-", file, (char *)0, envp);
		err = errno;
	}

	/*
	 * Obviously something is really wrong - I can't figure out
	 * how to execute this stupid shell, so I might as well give
	 * up in disgust ...
	 */
	(void) snprintf (arg0, sizeof arg0, _("Cannot execute %s"), file);
	errno = err;
	perror (arg0);
	return err;
}
Exemple #23
0
static RString GetNewWindow()
{
	HWND h = GetForegroundWindow();
	if( h == NULL )
		return "(NULL)";

	DWORD iProcessID;
	GetWindowThreadProcessId( h, &iProcessID );

	RString sName;
	GetProcessFileName( iProcessID, sName );

	sName = Basename(sName);

	return sName;
}
void CheckFailure(const char* file, int line,
                  const char* label, const char* fmt, ...) {
    char msg_buf[256];
    char file_buf[256];
    msg_buf[0] = '\0';
    if (fmt != NULL) {
        va_list ap;
        va_start(ap, fmt);
        PrintExtraMessage(fmt, ap, msg_buf, sizeof(msg_buf));
        va_end(ap);
    }
    __android_log_print(ANDROID_LOG_FATAL, DEBUG_TAG,
                        "Aborted: %s:%d: %s %s",
                        Basename(file, file_buf, sizeof(file_buf)),
                        line, label, msg_buf);
    abort();
}
Exemple #25
0
/*
 * @brief Loads the map or demo file and populates the server-controlled "config
 * strings."  We hand off the entity string to the game module, which will
 * load the rest.
 */
static void Sv_LoadMedia(const char *server, sv_state_t state) {
	int32_t i, map_size;

	strcpy(sv.name, server);
	strcpy(sv.config_strings[CS_NAME], server);

	if (state == SV_ACTIVE_DEMO) { // loading a demo
		sv.models[0] = Cm_LoadBsp(NULL, &map_size);

		sv.demo_file = Fs_OpenRead(va("demos/%s.dem", sv.name));
		svs.spawn_count = 0;

		Com_Print("  Loaded demo %s.\n", sv.name);
	} else { // loading a map
		g_snprintf(sv.config_strings[CS_MODELS], MAX_QPATH, "maps/%s.bsp", sv.name);

		sv.models[0] = Cm_LoadBsp(sv.config_strings[CS_MODELS], &map_size);

		const char *dir = Fs_RealDir(sv.config_strings[CS_MODELS]);
		if (g_str_has_suffix(dir, ".zip")) {
			g_strlcpy(sv.config_strings[CS_ZIP], Basename(dir), MAX_QPATH);
		}

		for (i = 1; i < Cm_NumModels(); i++) {

			char *s = sv.config_strings[CS_MODELS + i];
			g_snprintf(s, MAX_QPATH, "*%d", i);

			sv.models[i] = Cm_Model(s);
		}

		sv.state = SV_LOADING;

		Sv_InitWorld();

		svs.game->SpawnEntities(sv.name, Cm_EntityString());

		Sv_CreateBaseline();

		Com_Print("  Loaded map %s, %d entities.\n", sv.name, svs.game->num_edicts);
	}
	g_snprintf(sv.config_strings[CS_BSP_SIZE], MAX_QPATH, "%i", map_size);

	Cvar_FullSet("map_name", sv.name, CVAR_SERVER_INFO | CVAR_NO_SET);
}
/* ---------------------------------------------------------------
 * creat_r: 
 *      Given path of a file to be made, 
 *      get the parent's MINODE and ensure that it is a DIR
 *      and that the new file does not already exist in it 
 -------------------------------------------------------------------*/
void creat_r(char* path)
{
    MINODE* pip; 
    char* parent, *child; 
    int dev, pino; 
    
    // (1) Set device according to relative or absolute pathname 
    if(path[0] == '/')
        dev = root->dev; 
    else 
        dev = running->cwd->dev; 
    
    parent = strdup(Dirname(path)); 
    child = strdup(Basename(path));
    
    // (3) get in memory MINODE of parent directory 
        // First, get parent ino 
    pino = getino(&dev, parent); 
        // Then use it to load MINODE into minode[] table
    pip = iget(dev, pino);
    
    // (4)Verify pip
        // (4.1) was found 
    if(pip == NULL)
    {
        printf("Error: unable to locate %s\n", parent); 
    }
        // (4.2) is directory 
    else if(!isdir(pip))
    {
        printf("Error: %s is not a directory\n", parent);
    }
        // (4.3) does not already contain child
    else if(search(pip, child) != 0)    // the child was already found 
    {
        printf("Error: %s already exists in %s\n", child, parent); 
    }
    // (5) We've verified that parent path exists, is a directory 
        // and child does not exist in it, so add to it  
    else
        my_creat(pip,child); 
    
    iput(pip); 
    
}
Exemple #27
0
void BackgroundUtil::GetSongBGAnimations( const Song *pSong, const RString &sMatch, vector<RString> &vsPathsOut, vector<RString> &vsNamesOut )
{
	vsPathsOut.clear();
	if( sMatch.empty() )
	{
		GetDirListing( pSong->GetSongDir()+"*",    vsPathsOut, true, true );
	}
	else
	{
		GetDirListing( pSong->GetSongDir()+sMatch, vsPathsOut, true, true );
	}
	
	vsNamesOut.clear();
	FOREACH_CONST( RString, vsPathsOut, s )
		vsNamesOut.push_back( Basename(*s) );

	StripCvsAndSvn( vsPathsOut, vsNamesOut );
}
void
ImageSymbolLoader::Instrument
(
    IMG img
)
{
    string  ImageName       = IMG_Name(img);
    string  ImageNameExt    = Basename(ImageName);
    ADDRINT Base            = IMG_StartAddress(img);
    MemRange Module(Base, IMG_SizeMapped(img));

    Symbol::RefreshSymbolByIMG(img);

    cerr << "[pintool] Module " << MemRangeToString(Module) << " "
         << ImageNameExt << " "
         << Symbol::SymbolInfoForModuleAtAddress(Base)
         << endl;
}
Exemple #29
0
void BackgroundUtil::GetSongBitmaps( const Song *pSong, const RString &sMatch, vector<RString> &vsPathsOut, vector<RString> &vsNamesOut )
{
	vsPathsOut.clear();
	if( sMatch.empty() )
	{
		FILEMAN->GetDirListingWithMultipleExtensions(pSong->GetSongDir()+sMatch,
			ActorUtil::GetTypeExtensionList(FT_Bitmap), vsPathsOut, false, true);
	}
	else
	{
		GetDirListing( pSong->GetSongDir()+sMatch,			vsPathsOut, false, true );
	}

	vsNamesOut.clear();
	FOREACH_CONST( RString, vsPathsOut, s )
		vsNamesOut.push_back( Basename(*s) );

	StripCvsAndSvn( vsPathsOut, vsNamesOut );
}
int main_fold(const vector<string> &args)
{ 
  if (args.size() < 3 || args[2] == "-h")
  { 
    cout << "usage: " << Basename(args[0]) << " " << args[1] << " <line_width>" << endl;
    cout << "  Reads from stdin writes folded output to stdout" << endl;
    return 0;
  }

  int line_width = StrTo<int>(args[2]);
  FoldedOutStream out(cout, line_width);

  string line;
  while (getline(cin, line))
  { 
    out.Write(line + '\n');
  }

  return 0;
}