Ejemplo n.º 1
0
void sort_files_and_write(struct dir_info *dir)
{
	int i;
	struct priority_entry *entry;
	squashfs_inode inode;
	int duplicate_file;

	for(i = 65535; i >= 0; i--)
		for(entry = priority_list[i]; entry; entry = entry->next) {
			TRACE("%d: %s\n", i - 32768, pathname(entry->dir));
			if(entry->dir->inode->inode == SQUASHFS_INVALID_BLK) {
				write_file(&inode, entry->dir, &duplicate_file);
				INFO("file %s, uncompressed size %lld bytes %s"
					"\n", pathname(entry->dir),
					(long long)
					entry->dir->inode->buf.st_size,
					duplicate_file ? "DUPLICATE" : "");
				entry->dir->inode->inode = inode;
				entry->dir->inode->type = SQUASHFS_FILE_TYPE;
			} else
				INFO("file %s, uncompressed size %lld bytes "
					"LINK\n", pathname(entry->dir),
					(long long)
					entry->dir->inode->buf.st_size);
		}
}
Ejemplo n.º 2
0
QString KUnixSocketAddress::pretty() const
{
    QCString pname = pathname();
    if(pname.isEmpty())
        return i18n("<empty UNIX socket>");
    return QFile::decodeName(pathname());
}
Ejemplo n.º 3
0
Boolean shelf_push(int i, Boolean absolute, Boolean pushdir)
{
  FilePtr file = dirFile(shelfdir, i);
  String action;
  char path1[MAXPATHLEN+1], path2[MAXPATHLEN+1];

  root_modified = cur_modified = shelf_modified = cur_changed = False;
  if (file)
    if (!((action = push_action(fileType(file))) && *action) &&
	S_ISDIR(fileStats(file)->st_mode)) {
      return
	cur_chdir(resolve(path1, pathname(path2, dirName(shelfdir),
					  fileName(file))));
    } else {
      Boolean ret =
	filePush(shelfdir, i,
		 (pushdir && (fileStats(file)->st_mode &
			      (S_IXUSR | S_IXGRP | S_IXOTH)))?
		 dirName(curdir):NULL, absolute, True);
      update();
      return ret;
    }
  else
    return False;
}
Ejemplo n.º 4
0
void generate_file_priorities(struct dir_info *dir, int priority,
	struct stat *buf)
{
	struct dir_ent *dir_ent = dir->list;

	priority = get_priority(dir->pathname, buf, priority);

	for(; dir_ent; dir_ent = dir_ent->next) {
		struct stat *buf = &dir_ent->inode->buf;
		if(dir_ent->inode->root_entry)
			continue;

		switch(buf->st_mode & S_IFMT) {
			case S_IFREG:
				add_priority_list(dir_ent,
					get_priority(pathname(dir_ent), buf,
					priority));
				break;
			case S_IFDIR:
				generate_file_priorities(dir_ent->dir,
					priority, buf);
				break;
		}
	}
}
Ejemplo n.º 5
0
std::string sys::OSUnix::getTempName(const std::string& path,
                                     const std::string& prefix) const
{
    std::string name;
#if defined(_USE_MKSTEMP) || defined(__linux__) || defined(__linux) || defined(linux__)
    std::string pathname(path);
    pathname += "/" + prefix + "XXXXXX";
    std::vector<char> fullPath(pathname.size() + 1);
    strcpy(&fullPath[0], pathname.c_str());
    int ret = mkstemp(&fullPath[0]);
    if (ret == -1) name = "";
    else
    {
        name = &fullPath[0];
    }
#else
    CharWrapper tempname = tempnam(path.c_str(), prefix.c_str());
    if (tempname.get() == NULL)
        name = "";
    else
    {
        name = tempname.get();
        sys::File (name, sys::File::WRITE_ONLY, sys::File::CREATE);
    }
#endif
    if (name.empty())
    {
        throw except::Exception(Ctxt("Unable to create a temporary file"));
    }
    return name;
}
static	void	createkey (const char *keyname, const dki_t *list, const zconf_t *conf)
{
	const char *dir = "";
	dki_t	*dkp;

	if ( keyname == NULL || *keyname == '\0' )
		fatal ("Create key: no keyname!");

	dbg_val2 ("createkey: keyname %s, pathflag = %d\n", keyname, pathflag);
	/* search for already existent key to get the directory name */
	if ( pathflag && (dkp = (dki_t *)zkt_search (list, 0, keyname)) != NULL )
	{
		char    path[MAX_PATHSIZE+1];
		zconf_t localconf;

		dir = dkp->dname;
		pathname (path, sizeof (path), dir, LOCALCONF_FILE, NULL);
		if ( fileexist (path) )                 /* load local config file */
		{
			dbg_val ("Load local config file \"%s\"\n", path);
			memcpy (&localconf, conf, sizeof (zconf_t));
			conf = loadconfig (path, &localconf);
		}
	}
	
	if  ( zskflag )
		dkp = dki_new (dir, keyname, DKI_ZSK, conf->k_algo, conf->z_bits, conf->z_random, conf->z_life / DAYSEC);
	else
		dkp = dki_new (dir, keyname, DKI_KSK, conf->k_algo, conf->k_bits, conf->k_random, conf->k_life / DAYSEC);
	if ( dkp == NULL )
		fatal ("Can't create key %s: %s!\n", keyname, dki_geterrstr ());

	/* create a new key always in state published, which means "standby" for ksk */
	dki_setstatus (dkp, DKI_PUB);
}
Ejemplo n.º 7
0
int generate_file_priorities(struct dir_info *dir, int priority,
	struct stat *buf)
{
	int res;

	priority = get_priority(dir->pathname, buf, priority);

	while(dir->current_count < dir->count) {
		struct dir_ent *dir_ent = dir->list[dir->current_count++];
		struct stat *buf = &dir_ent->inode->buf;
		if(dir_ent->inode->root_entry)
			continue;

		switch(buf->st_mode & S_IFMT) {
			case S_IFREG:
				res = add_priority_list(dir_ent,
					get_priority(pathname(dir_ent), buf,
					priority));
				if(res == FALSE)
					return FALSE;
				break;
			case S_IFDIR:
				res = generate_file_priorities(dir_ent->dir,
					priority, buf);
				if(res == FALSE)
					return FALSE;
				break;
		}
	}
	dir->current_count = 0;

	return TRUE;
}
Ejemplo n.º 8
0
bool CPhotoPubDoc::WriteDefPages(void)
{
	char buf[MAX_BUF_SIZE];
	GetModuleFileName(NULL,buf,MAX_BUF_SIZE);
	CString pathname(buf);
	pathname=pathname.Left(pathname.ReverseFind('\\')+1);

	char tmpname[MAX_BUF_SIZE]="tmpXXXXXX";
	FILE *fptmp,*fpfmt;
	if (_mktemp_s(tmpname,MAX_BUF_SIZE))
		return false;
	if( fopen_s( &fptmp, pathname+tmpname, "w" ) )
		return false;
	if( fopen_s( &fpfmt, pathname+"pages.fmt", "r" ) )
		return false;
	size_t size=m_PreDefinedPages.size();
	for (size_t i=0;i<size;++i){
		fprintf_s(fptmp,"[%d]\n",i);
		m_PreDefinedPages[i]->SavePage(fptmp);
	}
	fprintf_s(fptmp,"%s","[End]");

	fclose(fptmp);
	fclose(fpfmt);

   if( remove( pathname+"pages.fmt" )  )
      return false;

   if (rename(pathname+tmpname,pathname+"pages.fmt"))
	   return false;


	return true;
}
Ejemplo n.º 9
0
std::string SBAssetHandler::checkPath(const std::string& path)
{
	boost::filesystem::path pathname(path);
	if( !boost::filesystem::exists( pathname ) )
	{
#if (BOOST_VERSION > 104400)
		LOG("Asset path \"%s\" not found.",  pathname.string().c_str());
#else
		LOG("Asset path \"%s\" not found.", pathname.native_file_string().c_str());
#endif
		return "";
	}

	if( boost::filesystem::is_directory( pathname ) ) // path indicates a directory
	{
		#if (BOOST_VERSION > 104400)
		LOG("Asset path \"%s\" is a directory.",  pathname.string().c_str());
#else
		LOG("Asset path \"%s\" is a directory.", pathname.native_file_string().c_str());
#endif
		return "";
	}

	std::string convertedPath = pathname.string();
#ifdef WIN32
	boost::replace_all(convertedPath, "\\", "/");
#endif

	return convertedPath;
}
Ejemplo n.º 10
0
/**
 *  Insert a formatted representation of the %arena onto the output stream 'o'.
 */
void Arena::insert(std::ostream& o) const
{
 /* Recurse through the list of arenas that runs through the parent attribute,
    building up a name of the form 'root/.../parent-arena/arena' in the string
    from which we inherit. Note that this list is short - no more than a dozen
    links, at most - and that each  recursive call pushes just two pointers on
    the stack, so the consumption of stack space is minimal...*/

    struct pathname : std::string
    {
        void traverse(const Arena& arena)                // Build up the name
        {
            if (ArenaPtr p = arena.parent())             // Has a parent arena?
            {
                traverse(*p);                            // ...traverse parent
                *this += '/';                            // ...add a delimiter
            }

            *this += arena.name();                       // Append arena name
        }

        pathname(const Arena& arena) {traverse(arena);}  // Traverse ancestors
    };

    o <<  "name=\""      << pathname(*this) << '"'       // Emit path name
      << ",available="   << bytes_t (available())        // Emit available()
      << ",allocated="   << bytes_t (allocated())        // Emit allocated()
      << ",peakusage="   << bytes_t (peakusage())        // Emit peakusage()
      << ",allocations=" << size_t  (allocations());     // Emit allocations()
}
Ejemplo n.º 11
0
void CUTS_BE_Project_File_Open_T <CUTS_CHAOS::Context, CUTS_BE_Impl_Node>::
generate (const CUTS_BE_Impl_Node & node)
{
  std::string pathname (CUTS_BE_OPTIONS ()->output_directory_);
  pathname += "/" + node.name_ + ".mpc";

  this->ctx_.project_.open (pathname.c_str ());
}
Ejemplo n.º 12
0
void CUTS_BE_Project_File_Open_T <CUTS_CHAOS::Context, CUTS_BE_IDL_Node>::
generate (const CUTS_BE_IDL_Node & node)
{
  // Construct the name of the project file.
  std::string pathname (CUTS_BE_OPTIONS ()->output_directory_);
  pathname += "/" + std::string (node.file_.name ()) + ".mpc";

  // Open the project for writing.
  this->ctx_.project_.open (pathname.c_str ());
}
Ejemplo n.º 13
0
void print_dir(inode_state& state) {
   cout << pathname(state.get_contents().at("."),
            state.get_root()->get_inode_nr()) << ":" << endl;
   for(auto elem : state.get_contents()) {
      cout << "\t" << elem.second->get_inode_nr() << " "
      << elem.second->size() << " "
      << elem.first << " "
      << endl;
   }
   cout << endl;
}
Ejemplo n.º 14
0
//
// CUTS_BE_Workspace_File_Open_T
//
void
CUTS_BE_Workspace_File_Open_T <CUTS_BE_CCM::Cpp::Context>::
generate (const std::string & name)
{
  // Construct the full pathname of the workspace.
  std::string pathname (CUTS_BE_OPTIONS ()->output_directory_);
  pathname += "/" + name + ".mwc";

  // Open the workspace file for writing.
  this->ctx_.workspace_.open (pathname.c_str ());
}
void ossimPlanetActionReceiver::setPathnameAndRegister(const std::string& newPath)
{
   // we will unregister if already registered
   //
   ossimPlanetActionReceiver* r = ossimPlanetActionRouter::instance()->receiver(pathname());
   if(r==this) // if we are ourselves then we can change our pathname
   {
      ossimPlanetActionRouter::instance()->unregisterReceiver(this);
   }      
   setPathname(newPath);
   ossimPlanetActionRouter::instance()->registerReceiver(this);
}
Ejemplo n.º 16
0
FilePath FilePath::operator+(const String &path) const
{
    FilePath pathname(AddPath(*this, path));

    pathname.pathType = this->pathType;
	if (this->pathType == PATH_EMPTY)
	{
		pathname.pathType = GetPathType(pathname.absolutePathname);
	}

    return pathname;
}
Ejemplo n.º 17
0
Boolean shelf_init(String shelf_path, int options)
{
  char path[MAXPATHLEN+1];

  root_modified = cur_modified = cur_changed = False;
  shelf_modified = True;
  strcpy(save_shelf_path, shelf_path);
  save_shelf_options = options;
  if (shelfdir)
    dirFree(shelfdir);
  shelf_no = default_shelf;
  if (shelf_dir(shelf_no))
    pathname(path, shelf_path, shelf_dir(shelf_no));
  else if (shelf_label(shelf_no))
    pathname(path, shelf_path, shelf_label(shelf_no));
  else
    strcpy(path, shelf_path);
  update_shelf_path(path);
  shelfdir = dirCreate(path, NULL, options);
  return dirReadFileInfo(shelfdir) != NULL;
}
Ejemplo n.º 18
0
/**
 * rotate log file
 * */
static int slog_rotate(slog_t * log, time_t cur)
{
	pthread_mutex_lock(&(log->lock));
	
	if(cur <= log->rotate_time)
	{
		pthread_mutex_unlock(&(log->lock));
		return 0;
	}

	log->rotate_time = slog_rotate_time(log);

	char* fmt = log->rotate_fmt;

	char rotate_fmt[PATH_MAX];
	if(NULL != log->rotate_fmt_cb)
	{
		log->rotate_fmt_cb(rotate_fmt);
		fmt = rotate_fmt;
	}

	// log rotate name
	cur -= log->rotate_period; // adjust time
	char fname[PATH_MAX];
	struct tm tm_s;
	size_t len = strftime(fname, sizeof(fname), fmt, localtime_r(&cur, &tm_s));
	fname[len] = '\0';

	if(0 != mkdir(pathname(fname)))
	{
		pthread_mutex_unlock(&(log->lock));
		return 1;
	}

	fclose(log->fp);

	if(0 == rename(log->full_name, fname))
	{
		if(NULL != log->rotate_cb)
		{
			log->rotate_cb(fname);
		}
	}
	else
	{
		perror("slog_rotate/rename()");
	}

	log->fp = fopen(log->full_name, "a");

	pthread_mutex_unlock(&(log->lock));
	return 0;
}
Ejemplo n.º 19
0
Boolean shelf_goto(int i)
{
  char path[MAXPATHLEN+1];

  root_modified = cur_modified = cur_changed = shelf_modified = False;
  if (i == shelf_no && dirIsReadable(shelfdir))
    return True;
  Wait();
  shelf_modified = True;
  dirFree(shelfdir);
  shelf_no = i;
  if (shelf_dir(shelf_no))
    pathname(path, save_shelf_path, shelf_dir(shelf_no));
  else if (shelf_label(shelf_no))
    pathname(path, save_shelf_path, shelf_label(shelf_no));
  else
    strcpy(path, save_shelf_path);
  update_shelf_path(path);
  shelfdir = dirCreate(path, NULL, save_shelf_options);
  Done();
  return dirReadFileInfo(shelfdir) != NULL;
}
Ejemplo n.º 20
0
int main(int argc, char *argv[])
{
    FILE *fp;
    const char *dir;
    const char *header = STD_HEADER_NAME;
    int i;

    if ((fp = fopen(POSC_HDR_NAME, "w")) == NULL) 
        PANIC(("Can't open '%s' for writing: %s\n", POSC_HDR_NAME, strerror(errno)));

    dir = pathname(findhdrloc(header), 1);
    printf("'%s'\n", dir);
    writehdrdir(fp, NULL, dir);

    for (i = 0; stdheader[i] != NULL; ++i) {
        const char *loc;

        header = stdheader[i];
        printf("%s: ", header);
        loc = pathname(findhdrloc(header), 0);
        printf("'%s'\n", loc);
        writehdrdir(fp, header, loc);
    }

    for (i = 1; i < argc; ++i) {
        const char *loc;

        header = argv[i];
        printf("%s: ", header);
        loc = pathname(findhdrloc(header), 0);
        printf("'%s'\n", loc);
        writehdrdir(fp, header, loc);
    }

    fclose(fp);
    remove("posc_findhdrdir.err");

    return EXIT_SUCCESS;
}
Ejemplo n.º 21
0
	scrolly = m_bg1scrolly;
	for (i = 0; i < 256; i++)
		m_bg1_tilemap->set_scrollx((i + scrolly) & 0xff, m_rasterram[i]);
	m_bg1_tilemap->set_scrolly(0, scrolly);

	screen.priority().fill(0, cliprect);

	m_bg1_tilemap->draw(screen, bitmap, cliprect, 0, 0);
	m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spritepalettebank, machine(), bitmap, cliprect, screen.priority(), 0);
	m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spritepalettebank, machine(), bitmap, cliprect, screen.priority(), 1);
	return 0;
}


UINT32 aerofgt_state::screen_update_karatblz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	m_bg1_tilemap->set_scrollx(0, m_bg1scrollx - 8);
	m_bg1_tilemap->set_scrolly(0, m_bg1scrolly);
	m_bg2_tilemap->set_scrollx(0, m_bg2scrollx - 4);
	m_bg2_tilemap->set_scrolly(0, m_bg2scrolly);

	screen.priority().fill(0, cliprect);
Ejemplo n.º 22
0
// true if filename ends in ".sc"
bool isValidSourceFileName(char *filename)
{
	int len = strlen(filename);
	bool validExtension = (len>3 && strncmp(filename+len-3, ".sc", 3) == 0)
            || (len>7 && strncmp(filename+len-7, ".sc.rtf", 7) == 0);
	if (!validExtension)
		return false;

	boost::filesystem::path pathname(filename);

	if (pathname.filename().c_str()[0] == '.') // hidden filename
		return false;

	return true;
}
/*
 * Function: native_restorecon
 * Purpose: restore default SELinux security context
 * Parameters: pathname: the pathname for the file to be relabeled
 * Returns: boolean: (true) file label successfully restored, (false) otherwise
 * Exceptions: none
 */
static jboolean native_restorecon(JNIEnv *env, jobject, jstring pathnameStr) {
    if (isSELinuxDisabled) {
        return true;
    }

    ScopedUtfChars pathname(env, pathnameStr);
    if (pathname.c_str() == NULL) {
        ALOGV("restorecon(%p) => threw exception", pathnameStr);
        return false;
    }

    int ret = selinux_android_restorecon(pathname.c_str());
    ALOGV("restorecon(%s) => %d", pathname.c_str(), ret);
    return (ret == 0);
}
Ejemplo n.º 24
0
inline void JarFileParser::save_parser_in_cache(JVM_SINGLE_ARG_TRAPS) {
  const int max = MAX_CACHED_PARSERS < MaxCachedJarParsers ?
                  MAX_CACHED_PARSERS : MaxCachedJarParsers;
  int found = 0;
  int oldest = max_jint;

  // (1) Find a location the _cached_parsers[]
  for (int i=0; i<max; i++) {
    int ref = _cached_parsers[i];
    if (ref < 0) { // This slot is not used.
      found = i;
      break;
    } else {
      JarFileParser::Raw parser = ObjectHeap::get_global_ref_object(ref);
      if (parser.is_null()) {
        // The cached parser has been GC'ed
        found = i;
        break;
      }
      if (parser().timestamp() < oldest) {
        // It's not GC'ed, let use it if it's the oldest of the non-yet-GC'ed
        // parsers.
        oldest = parser().timestamp();
        found = i;
      }
    }
  }

  dispose( found );

  const int newref = ObjectHeap::register_global_ref_object(this,
    ObjectHeap::WEAK JVM_MUST_SUCCEED);
  if( newref >= 0 ) {
    _cached_parsers[found] = newref;
  }

#ifndef ENABLE_TTY_TRACE
  if (TraceJarCache) {
    TTY_TRACE(("JAR: parser cached: %d ", found));
    TypeArray::Raw stored_name = pathname();
    JvmPathChar *data = (JvmPathChar*)stored_name().byte_base_address();
    for (int n=0; n<stored_name().length(); n++) {
      TTY_TRACE(("%c", (char)data[n]));
    }
    TTY_TRACE_CR((""));
  }
#endif
}
Ejemplo n.º 25
0
// ストレージ処理用データの初期化
void
PSD::startStorage()
{
	if (!storageStarted) {
		storageStarted = true;
		// レイヤ検索用の情報を生成
		int count = (int)layerList.size();
		for (int i=count-1;i>=0;i--) {
			psd::LayerInfo &lay = layerList[i];
			if (lay.layerType == psd::LAYER_TYPE_NORMAL) {
				pathMap[pathname(lay)][path_layname(lay)] = i;
				layerIdIdxMap[lay.layerId] = i;
			}
		}
	}
}
Ejemplo n.º 26
0
static int _FileExtension(const char* file_name)
{
	std::string pathname(file_name);
	size_t dot_pos = pathname.rfind('.');
	if (dot_pos != std::string::npos) {
		const char* ext = &pathname.c_str()[dot_pos + 1];
		if (strcmp(ext, "obj") == 0)
			return FILE_EXT_OBJ;
		else if (strcmp(ext, "abc") == 0)
			return FILE_EXT_ABC;
		else
			return FILE_EXT_UNKNOWN;
	}
	else
		return FILE_EXT_UNKNOWN;
}
Ejemplo n.º 27
0
DTerr ImporterImageJPG::import (TextureResourceCube *target, std::string args)
{
    // Convert path to this platform
	FilePath pathname(target->path());
    
    DTuint                      width;
    DTuint                      height;
    std::shared_ptr<DTubyte>    data;
    DT3GLTextelFormat            format;

    import(pathname, args, width, height, data, format);

    // TODO: Set textels

	return DT3_ERR_NONE;
}
Ejemplo n.º 28
0
/**
 * open a log using default params, and return the handle.
 * */
slog_t* slog_open(const char * full_name)
{
	if(strlen(full_name) + strlen(SLOG_ROTATE_FORMAT_DEFAULT) >= PATH_MAX)
	{
		return NULL;
	}

	slog_t * log = (slog_t*)malloc(sizeof(slog_t));
	if(NULL == log)
	{
		return NULL;
	}

	log->lvl = SLOG_LEVEL_DEFAULT;
	pthread_mutex_init(&(log->lock), NULL);

	log->running       = 1;
	log->rotate_period = SLOG_ROTATE_PERIOD_DEFAULT;
	log->rotate_time   = slog_rotate_time(log);
	log->rotate_fmt_cb = NULL;

	strncpy(log->full_name, full_name, sizeof(log->full_name));
	strncpy(log->rotate_fmt, full_name, sizeof(log->rotate_fmt));
	strcat(log->rotate_fmt, SLOG_ROTATE_FORMAT_DEFAULT);

	if(0 != mkdir(pathname(log->full_name)))
	{
		free(log);
		return NULL;
	}

	log->fp = fopen(log->full_name, "a");
	if(NULL == log->fp)
	{
		free(log);
		return NULL;
	}

	if(0 != pthread_create(&log->tid, NULL, slog_rotate_thread, log))
	{
		fclose(log->fp);
		free(log);
		return NULL;
	}
	return log;
}
Ejemplo n.º 29
0
const wxImage& LoadImageAny(
	wxImage& dest, bool useTheme, wxFileName& base, const wxChar* filename, IEmbeddedImage& onFail )
{
	if (useTheme && base.DirExists())
	{
		wxFileName pathname(base.GetFullPath(), filename);

		const wxChar* extensions[3] = {L"png", L"jpg", L"bmp"};
		for (size_t i = 0; i < sizeof(extensions)/sizeof(extensions[0]); ++i)
		{
			pathname.SetExt(extensions[i]);
			if (pathname.FileExists() && dest.LoadFile(pathname.GetFullPath()))
				return dest;
		}
	}

	return dest = onFail.Get();
}
Ejemplo n.º 30
0
//DONEDONEDONEDONEDONEDONEDONE///////////////////////////////////////
void fn_ls (inode_state& state, const wordvec& words){
   bool r = false;
   string orig = pathname(state.get_contents().at("."),
                  state.get_root()->get_inode_nr());
   if (words.size() > 1) {
      for(auto word = words.begin()+1; word != words.end(); word++) {
         if((*word)[0] == '/') r = true;
         state.set_cwd(split(*word,"/"), r);
         print_dir(state);
         state.set_cwd(split(orig,"/"),true);
      }
   }
   else
      print_dir(state);         

   DEBUGF ('c', state);
   DEBUGF ('c', words);
}