Exemple #1
0
Chan*
devattach(int dc, char *spec)
{
	if (0) print_func_entry();
	Chan *c;
	char *buf;

	/*
	 * There are no error checks here because
	 * this can only be called from the driver of dc
	 * which pretty much guarantees devtabget will
	 * succeed.
	 */
	c = newchan();
	mkqid(&c->qid, 0, 0, QTDIR);
	c->dev = devtabget(dc, 0);
	if(spec == nil)
		spec = "";
	buf = smalloc(1+UTFmax+strlen(spec)+1);
	sprint(buf, "#%C%s", dc, spec);
	c->path = newpath(buf);
	free(buf);
	if (0) print_func_exit();
	return c;
}
Exemple #2
0
static Chan*
fsattach(char *spec)
{
	struct stat st;
	Chan *c;
	UnixFd *ufd;
	int dev;
	
	dev = 1;
	if(spec && spec[0]){
		snprint(up->genbuf, sizeof up->genbuf, "no file system #%C%s", FsChar, spec);
		error(up->genbuf);
	}

	if(stat("/", &st) < 0)
		oserror();

	c = devattach(FsChar, 0);
	ufd = mallocz(sizeof(UnixFd), 1);
	ufd->path = newpath("/");
	ufd->fd = -1;

	c->aux = ufd;
	c->dev = dev;
	c->qid = fsqid(&st);
	
	if(Trace)
		print("fsattach /\n");

	return c;
}
Exemple #3
0
/*
 * Walks elems starting at f.
 * Ok if nelems is 0.
 */
static Path*
walkpath(Memblk *f, char *elems[], int nelems)
{
	int i;
	Memblk *nf;
	Path *p;

	p = newpath(f);
	if(catcherror()){
		putpath(p);
		error(nil);
	}
	isfile(f);
	for(i = 0; i < nelems; i++){
		if((f->d.mode&DMDIR) == 0)
			error("not a directory");
		rwlock(f, Rd);
		if(catcherror()){
			rwunlock(f, Rd);
			error("walk: %r");
		}
		nf = dfwalk(f, elems[i], Rd);
		rwunlock(f, Rd);
		addelem(&p, nf);
		mbput(nf);
		f = nf;
		USED(&f);	/* in case of error() */
		noerror();
	}
	noerror();
	return p;
}
Exemple #4
0
void wxFileDirPickerCtrlBase::UpdatePickerFromTextCtrl()
{
    wxASSERT(m_text);

    if (m_bIgnoreNextTextCtrlUpdate)
    {
        // ignore this update
        m_bIgnoreNextTextCtrlUpdate = false;
        return;
    }

    // remove the eventually present path-separator from the end of the textctrl
    // string otherwise we would generate a wxFileDirPickerEvent when changing
    // from e.g. /home/user to /home/user/ and we want to avoid it !
    wxString newpath(GetTextCtrlValue());
    if (!CheckPath(newpath))
        return;       // invalid user input

    if (m_pickerIface->GetPath() != newpath)
    {
        m_pickerIface->SetPath(newpath);

        // update current working directory, if necessary
        // NOTE: the path separator is required because if newpath is "C:"
        //       then no change would happen
        if (IsCwdToUpdate())
            wxSetWorkingDirectory(newpath);

        // fire an event
        wxFileDirPickerEvent event(GetEventType(), this, GetId(), newpath);
        GetEventHandler()->ProcessEvent(event);
    }
}
Exemple #5
0
void wxFileDirPickerCtrlBase::UpdatePickerFromTextCtrl()
{
    wxASSERT(m_text);

    // remove the eventually present path-separator from the end of the textctrl
    // string otherwise we would generate a wxFileDirPickerEvent when changing
    // from e.g. /home/user to /home/user/ and we want to avoid it !
    wxString newpath(GetTextCtrlValue());

    // Notice that we use to check here whether the current path is valid, i.e.
    // if the corresponding file or directory exists for the controls with
    // wxFLP_FILE_MUST_EXIST or wxDIRP_DIR_MUST_EXIST flag, however we don't do
    // this any more as we still must notify the program about any changes in
    // the control, otherwise its view of it would be different from what is
    // actually shown on the screen, resulting in very confusing UI.

    if (m_pickerIface->GetPath() != newpath)
    {
        m_pickerIface->SetPath(newpath);

        // update current working directory, if necessary
        // NOTE: the path separator is required because if newpath is "C:"
        //       then no change would happen
        if (IsCwdToUpdate())
            wxSetWorkingDirectory(newpath);

        // fire an event
        wxFileDirPickerEvent event(GetEventType(), this, GetId(), newpath);
        GetEventHandler()->ProcessEvent(event);
    }
}
Exemple #6
0
	std::string real_path(const std::string& path)
	{
		char* tmp = realpath(path.c_str(), NULL);
	    std::string newpath(tmp);
		free(tmp);
		return newpath;
	}
Exemple #7
0
/*
 *  starting place for first process
 */
void
init0(void)
{
	up->nerrlab = 0;

	spllo();

	/*
	 * These are o.k. because rootinit is null.
	 * Then early kproc's will have a root and dot.
	 */
	up->slash = namec("#/", Atodir, 0, 0);
	pathclose(up->slash->path);
	up->slash->path = newpath("/");
	up->dot = cclone(up->slash);

	chandevinit();

	if(!waserror()){
		ksetenv("terminal", "bitsy", 0);
		ksetenv("cputype", "arm", 0);
		if(cpuserver)
			ksetenv("service", "cpu", 0);
		else
			ksetenv("service", "terminal", 0);
		poperror();
	}
	kproc("alarm", alarmkproc, 0);
	kproc("power", powerkproc, 0);

	touser(sp);
}
Exemple #8
0
Bool_t
LoadDummy()
{
  const char*  alice_root = gSystem->Getenv("ALICE_ROOT");
  const char*  dirs[]     = { "", "include", "ITS", 0 };
  const char** d          = dirs;
  TString newpath("-DCOMPILING=1 ");
  newpath += gSystem->GetIncludePath();
  do {
    TString flag(Form("-I%s/%s", alice_root, *d));
    if (newpath.Index(flag) == TString::kNPOS) {
      std::cerr << "Adding " << flag << std::endl;
      newpath += " ";
      newpath += flag;
    }
  } while (*(++d));

  gSystem->SetIncludePath(newpath.Data());
  std::cout << "Include path is\n\t" << gSystem->GetIncludePath() << std::endl;
  gROOT->LoadMacro("Dummy.C+g");
  if (!gROOT->GetClass("Dummy<AliITSvPPRasymmFMD>")) {
    std::cerr << "Failed to make DummyITS" << std::endl;
    return kFALSE;
  }
  return kTRUE;
}
Exemple #9
0
bool FileSystem::rename(const std::string &oldname, const std::string &newname)
{
  std::string oldpath(normalize_path(oldname));
  std::string newpath(normalize_path(newname));

  if (std::rename(oldpath.c_str(), newpath.c_str()) != 0) return false;
  return true;
}
Exemple #10
0
// poly makes either a polygon or polyline
void poly(VGfloat * x, VGfloat * y, VGint n, VGbitfield flag) {
	VGfloat points[n * 2];
	VGPath path = newpath();
	interleave(x, y, n, points);
	vguPolygon(path, points, n, VG_FALSE);
	vgDrawPath(path, flag);
	vgDestroyPath(path);
}
// Creates an empty File
// Throws ex::filesystem::AlreadyThere
void File::write(Conflict c) {
    if( exists() ){
        if(c == LEAVE)
            Throw(ex::filesystem::AlreadyThere,m_name.string());
        else if(c == NEW)
            path(newpath());
    }
    open(WRITE);
}
// Creates a File using string, B+T
// Throws ex::filesystem::AlreadyThere
void File::write(const std::string& data,Conflict c) {
    if( exists() ){
        if(c == LEAVE)
            Throw(ex::filesystem::AlreadyThere,m_name.string());
        else if(c == NEW)
            path(newpath());
    }
    open(WRITE);
    m_stream << data;
}
// Creates a File using istream, B+T ??
// Throws ex::filesystem::AlreadyThere
void File::write(std::istream& data,Conflict c,uintmax_t n){
    if( exists() ){
        if(c == LEAVE)
            Throw(ex::filesystem::AlreadyThere,m_name.string());
        else if(c == NEW)
            path(newpath());
    }
    open(WRITE);
    streamCopy(data, n);
}
Exemple #14
0
void ImportDlg::OnBrowseForOutputFolder(wxCommandEvent& event)
{
    wxString curtext = m_textName->GetValue();
    wxFileName fn(curtext);
    wxString dir = wxDirSelector();
    if(dir.IsEmpty()) return;

    wxFileName newpath(dir, fn.GetFullName());
    m_textName->ChangeValue(newpath.GetFullPath());
}
Exemple #15
0
/* bind/construct representative of an internal cluster of a model graph */
static rep_t model_clust(Agraph_t *model, Agraph_t *origclust)
{
	rep_t		rep;

	rep = association(model,origclust);
	if (rep.type) return rep;

	rep.p = newpath(model,NILnode,GD_minrank(origclust),NILnode,GD_maxrank(origclust));
	rep.type = SKELETON;
	associate(model,origclust,rep);
	return rep;
}
Exemple #16
0
void
init0(void)
{
//	char **p, *q, name[KNAMELEN];
//	int n;
	char buf[2*KNAMELEN];

	up->nerrlab = 0;

	spllo();

	/*
	 * These are o.k. because rootinit is null.
	 * Then early kproc's will have a root and dot.
	 */
	up->slash = namec("#/", Atodir, 0, 0);
	pathclose(up->slash->path);
	up->slash->path = newpath("/");
	up->dot = cclone(up->slash);

	chandevinit();

	if(!waserror()){
		snprint(buf, sizeof(buf), "power %s mtx", conffile);
		ksetenv("terminal", buf, 0);
		ksetenv("cputype", "power", 0);
		if(cpuserver)
			ksetenv("service", "cpu", 0);
		else
			ksetenv("service", "terminal", 0);
		
/*
		for(p = confenv; *p; p++) {
			q = strchr(p[0], '=');
			if(q == 0)
				continue;
			n = q-p[0];
			if(n >= KNAMELEN)
				n = KNAMELEN-1;
			memmove(name, p[0], n);
			name[n] = 0;
			if(name[0] != '*')
				ksetenv(name, q+1, 0);
			ksetenv(name, q+1, 1);
		}
*/
		poperror();
	}
	kproc("alarm", alarmkproc, 0);
	kproc("mmusweep", mmusweep, 0);
	touser((void*)(USTKTOP-8));
}
Exemple #17
0
static void labelc(float x, float y, float xw, float yw, char *str, float s)
{
 	stroke();
	newpath();
   	setgray(1.0);
	rectfill(x,y,xw,yw);
 	setgray(0.0);
	setfont("Helvetica-Bold",s);
        moveto(x+xw,y);
 	rotate(90.);
	show(str);
	rotate(-90.);
   	stroke();
}
Exemple #18
0
/* 	draw a label on contour		*/
static void labelc(float x, float y, float xw, float yw, char *str,
	float size, char *font, char *color)
{
 	stroke();
	gsave();
	newpath();
   	setcolor("white");
	rectfill(x,y,xw,yw);
 	setcolor(color);
	setfont(font,size);
        moveto(x+xw,y);
 	rotate(90.);
	show(str);
	rotate(-90.);
   	stroke();
	grestore();
}
Exemple #19
0
static Chan*
fsattach(char *spec)
{
	struct stat st;
	Chan *c;
	UnixFd *ufd;
	int plan9, dev;
	
	dev = 1;
	plan9 = 0;
	if(spec && spec[0]){
		if(strcmp(spec, "plan9") == 0) {
			plan9 = 1;
			dev = 2;
		} else{
			snprint(up->genbuf, sizeof up->genbuf, "no file system #%C%s", FsChar, spec);
			error(up->genbuf);
		}
	}

	if(plan9){
		if(localroot == nil)
			error("no #Zplan9 root without -r");
		if(stat(localroot, &st) < 0)
			oserror();
	}else{
		if(stat("/", &st) < 0)
			oserror();
	}

	c = devattach(FsChar, spec);
	ufd = mallocz(sizeof(UnixFd), 1);
	ufd->path = newpath("/");
	ufd->plan9 = plan9;
	ufd->fd = -1;

	c->aux = ufd;
	c->dev = dev;
	c->qid = fsqid(&st);
	
	if(Trace)
		print("fsattach /\n");

	return c;
}
Exemple #20
0
static void model_edge(Agraph_t *model, Agedge_t *orig)
{
	Agedge_t	*e;
	Agnode_t	*low, *high, *u, *v;
	port_t		lowport, highport;
	vpath_t		*path;
	rep_t			rep;
	int				i;

	rep = association(model,orig);
	if (rep.type == 0) {
		low = orig->tail; high = orig->head;
		getlowhigh(&low,&high);
		u = association(model,low).p; assert(u);
		v = association(model,high).p; assert(v);
		path = newpath(model,u,ND_rank(low),v,ND_rank(high));
		rep.type = PATH;
		rep.p = path;
		associate(model,orig,rep);
	}
	else path = rep.p;

	/* merge the attributes of orig */
	for (i = path->low; i < path->high; i++) {
		e = path->e[i];
		ED_xpenalty(e) += ED_xpenalty(orig);
		ED_weight(e) += ED_weight(orig);
	}

	/* deal with ports.  note that ends could be swapped! */
	if (ND_rank(orig->tail) <= ND_rank(orig->head)) {
		lowport = ED_tailport(orig);
		highport = ED_headport(orig);
	}
	else {
		highport = ED_tailport(orig);
		lowport = ED_headport(orig);
	}
	if (lowport.defined)
		path->avgtailport = ((path->weight * path->avgtailport) + ED_weight(orig) * lowport.p.x) / (path->weight + ED_weight(orig));
	if (highport.defined)
		path->avgheadport = ((path->weight * path->avgheadport) + ED_weight(orig) * highport.p.x) / (path->weight + ED_weight(orig));
	path->weight += ED_weight(orig);
}
Exemple #21
0
/*
 *  starting place for first process
 */
void
init0(void)
{
	int i;
	char buf[2*KNAMELEN];

	up->nerrlab = 0;
	coherence();
	spllo();

	/*
	 * These are o.k. because rootinit is null.
	 * Then early kproc's will have a root and dot.
	 */
	up->slash = namec("#/", Atodir, 0, 0);
	pathclose(up->slash->path);
	up->slash->path = newpath("/");
	up->dot = cclone(up->slash);

	chandevinit();

	if(!waserror()){
		snprint(buf, sizeof(buf), "%s %s", "ARM", conffile);
		ksetenv("terminal", buf, 0);
		ksetenv("cputype", "arm", 0);
		if(cpuserver)
			ksetenv("service", "cpu", 0);
		else
			ksetenv("service", "terminal", 0);
		snprint(buf, sizeof(buf), "-a %s", getethermac());
		ksetenv("etherargs", buf, 0);

		/* convert plan9.ini variables to #e and #ec */
		for(i = 0; i < nconf; i++) {
			ksetenv(confname[i], confval[i], 0);
			ksetenv(confname[i], confval[i], 1);
		}
		poperror();
	}
	kproc("alarm", alarmkproc, 0);
	touser(sp);
	assert(0);			/* shouldn't have returned */
}
Exemple #22
0
static str
pathiterate (str path, str *sch, 
	     int recdepth = 0, bool firsttime = false)
{
//   warn << print_indent (recdepth) << "iteratepath: " << path << "\n";
  str s = pathexpand (path, sch, recdepth);
  if (path == s && !firsttime)
    return path;

  vec<str> components;
  split (&components, "/", s);
  str newpath ("");
  for (unsigned int i = 1; i < components.size (); i++) {
    newpath = pathiterate (newpath << "/" << components[i], sch,
			   recdepth + 5);
//     warn << print_indent (recdepth) << newpath << "\n";
  }
  return newpath;
}
bool RedirectNetworkAccessManager::redirectPath(QString &path)
{
    bool ret = false;
    if ((m_prgbase1.length() > 0) && (m_docbase.length() > 0)) {
        if (path == m_prgbase3) {
            /* program html */
        } else if (path.startsWith(m_prgbase2)) {
            /* program lib */
        } else if (path.startsWith(m_prgbase1)) {
            /* document related resource */
            QString newpath(m_docbase + path.right(path.length() - m_prgbase1.length()));
            path = newpath;
            ret = true;
        } else {
            /* absolute resource */
        }
    }
    return ret;
}
Exemple #24
0
void
init0(void)
{
	int i;
	char buf[2*KNAMELEN];

	up->nerrlab = 0;

	spllo();

	/*
	 * These are o.k. because rootinit is null.
	 * Then early kproc's will have a root and dot.
	 */
	up->slash = namec("#/", Atodir, 0, 0);
	pathclose(up->slash->path);
	up->slash->path = newpath("/");
	up->dot = cclone(up->slash);

	chandevinit();

	if(0 && !waserror()){			/* not needed by boot */
		snprint(buf, sizeof(buf), "%s %s", arch->id, conffile);
		ksetenv("terminal", buf, 0);
		ksetenv("cputype", "386", 0);
		if(cpuserver)
			ksetenv("service", "cpu", 0);
		else
			ksetenv("service", "terminal", 0);
		for(i = 0; i < nconf; i++){
			if(confname[i][0] != '*')
				ksetenv(confname[i], confval[i], 0);
			ksetenv(confname[i], confval[i], 1);
		}
		poperror();
	}
	kproc("alarm", alarmkproc, 0);

	conschan = enamecopen("#c/cons", ORDWR);
	bootloadproc(0);
	panic("bootloadproc returned");
}
Exemple #25
0
void
init0(void)
{
	int i;
	char buf[2*KNAMELEN];

	up->nerrlab = 0;

	spllo();

	/*
	 * These are o.k. because rootinit is null.
	 * Then early kproc's will have a root and dot.
	 */
	up->slash = namec("#/", Atodir, 0, 0);
	pathclose(up->slash->path);
	up->slash->path = newpath("/");
	up->dot = cclone(up->slash);

	chandevinit();

	if(!waserror()){
		snprint(buf, sizeof(buf), "alpha %s alphapc", conffile);
		ksetenv("terminal", buf, 0);
		ksetenv("cputype", "alpha", 0);
		if(cpuserver)
			ksetenv("service", "cpu", 0);
		else
			ksetenv("service", "terminal", 0);
		for(i = 0; i < nconf; i++)
			if(confname[i]){
				if(confname[i][0] != '*')
					ksetenv(confname[i], confval[i], 0);
				ksetenv(confname[i], confval[i], 1);
			}
		poperror();
	}

	kproc("alarm", alarmkproc, 0);
	touser((uchar*)(USTKTOP - sizeof(argbuf)));
}
Exemple #26
0
void
init0(void)
{
	Mach *m = machp();
	char buf[2*KNAMELEN];

	m->externup->nerrlab = 0;

	/*
	 * if(consuart == nil)
	 * i8250console("0");
	 */
	spllo();

	/*
	 * These are o.k. because rootinit is null.
	 * Then early kproc's will have a root and dot.
	 */
	m->externup->slash = namec("#/", Atodir, 0, 0);
	pathclose(m->externup->slash->path);
	m->externup->slash->path = newpath("/");
	m->externup->dot = cclone(m->externup->slash);

	devtabinit();

	if(!waserror()){
		snprint(buf, sizeof(buf), "%s %s", "AMD64", conffile);
		ksetenv("terminal", buf, 0);
		ksetenv("cputype", cputype, 0);
		if(cpuserver)
			ksetenv("service", "cpu", 0);
		else
			ksetenv("service", "terminal", 0);
		ksetenv("pgsz", "2097152", 0);
		// no longer. 	confsetenv();
		poperror();
	}
	kproc("alarm", alarmkproc, 0);
	//debugtouser((void *)UTZERO);
	touser(sp);
}
Exemple #27
0
void
init0(void)
{
//	char **p, *q, name[KNAMELEN];
	int i;
	char buf[2*KNAMELEN];

	up->nerrlab = 0;
	spllo();

	/*
	 * These are o.k. because rootinit is null.
	 * Then early kproc's will have a root and dot.
	 */
	up->slash = namec("#/", Atodir, 0, 0);
	pathclose(up->slash->path);
	up->slash->path = newpath("/");
	up->dot = cclone(up->slash);

	chandevinit();

	if(!waserror()){
		snprint(buf, sizeof(buf), "power %s mtx", conffile);
		ksetenv("terminal", buf, 0);
		ksetenv("cputype", "power", 0);
		if(cpuserver)
			ksetenv("service", "cpu", 0);
		else
			ksetenv("service", "terminal", 0);

		for(i = 0; i < nconf; i++){
			if(plan9ini[i].name[0] != '*')
				ksetenv(plan9ini[i].name, plan9ini[i].val, 0);
			ksetenv(plan9ini[i].name, plan9ini[i].val, 1);
		}
		poperror();
	}
	kproc("alarm", alarmkproc, 0);
	kproc("mmusweep", mmusweep, 0);
	touser((void*)(USTKTOP-sizeof(Tos)));
}
// Copies a File to another file
// Throws fs::filesystem_error, ex::filesystem::AlreadyThere,
// ex::filesystem::NotThere
void File::copy(const fs::path& tos,Conflict c) {
    fs::path toss = tos;
    if (!exists())
        Throw(ex::filesystem::NotThere,path().string());
    // To consider paths like "hari/shiva/"
    Node to(tos);
    if( (to.exists() && to.what() == DIRECTORY) || (to.filename() == "." || to.filename() == ".."))
        toss /= filename();

    File too(toss);
    if( too.exists() ){
        if(c==LEAVE)
            Throw(ex::filesystem::AlreadyThere,too.path().string());
        else if (c==NEW)
            path(newpath());
    }
    close();

    if( too.path().has_parent_path())
        Directory(too.parentpath().string()).create();
    fs::copy(path(),too.path());
}
Exemple #29
0
/* bind/construct representative of an internal node in a model graph */
static rep_t model_intnode(Agraph_t *model, Agnode_t *orig)
{
	int				nr;
	rep_t			rep;
	Agnode_t	*v;
	
	rep = association(model,orig);
	if (rep.type) return rep;
	
	nr = ND_ranksize(orig);
	if (nr <= 1) {			/* simple case */
		v = rep.p = agnode(model,orig->name);
		rep.type = NODE;
		ND_rank(v) = ND_rank(orig);
	}
	else {							/* multi-rank node case */
		rep.p = newpath(model,NILnode,ND_rank(orig),NILnode,ND_rank(orig)+nr-1);
		rep.type = TALLNODE;
	}
	associate(model,orig,rep);
	return rep;
}
bool CompileMaps(const char *ext, MapScriptCompiler *compiler, char *directory = NULL)
{
	if (!directory)
		directory = ".";

	std::string pattern = std::string(directory);
	pattern.append("/*");

	std::vector<std::string> filenames;
	listFilePattern(filenames, pattern.c_str());
	for(std::vector<std::string>::iterator i = filenames.begin();
		i != filenames.end();
		i++)
	{
		if (ExtensionIs(i->c_str(),"map"))
		{
			std::string fullpath(directory);
			fullpath.append("/");
			fullpath.append(*i);

			char *s = stripext(fullpath.c_str());
			if (Exist(va("%s.%s", s,ext))) 
				if(!compiler->CompileMap(s))
					return false;
		}
		else if (i->at(0) != '.')
		{
			// for now, if it's not a .map then try to use it as a directory
			std::string newpath(directory);
			newpath.append("/");
			newpath.append(*i);
			CompileMaps(ext,compiler,(char *)newpath.c_str());
		}
	}


	//log ("");
	return true;
}