예제 #1
0
int FileMgr::createParent(const char *pName) {
	char *buf = new char [ strlen(pName) + 1 ];
	int retCode = 0;
	
	strcpy(buf, pName);
	int end = strlen(buf) - 1;
	while (end) {
		if ((buf[end] == '/') || (buf[end] == '\\'))
			break;
		end--;
	}
	buf[end] = 0;
	if (strlen(buf)>0) {
		if (access(buf, 02)) {  // not exists with write access?
			if ((retCode = mkdir(buf
#ifndef WIN32
					, 0755
#endif
					))) {
				createParent(buf);
				retCode = mkdir(buf
#ifndef WIN32
					, 0755
#endif
					);
			}
		}
	}
	else retCode = -1;
	delete [] buf;
	return retCode;
}
예제 #2
0
int main(int argc, char **argv)
{
    KCmdLineArgs::init(argc, argv, &aboutData);

    KCmdLineOptions options;
    options.add("embed <winid>", ki18n("Makes the dialog transient for an X app specified by winid"));
    options.add("+[URL]", ki18n("URL to install"));
    KCmdLineArgs::addCmdLineOptions(options);

    QSet<KUrl>   urls;
    KCmdLineArgs *args(KCmdLineArgs::parsedArgs());

    for(int i=0; i < args->count(); i++)
        urls.insert(args->url(i));

    if(urls.count())
    {

        KApplication    app;
        QString         opt(args->getOption("embed"));
        KFI::CInstaller inst(createParent(opt.size() ? opt.toInt(0, 16) : 0));

        return inst.install(urls);
    }

    return -1;
}
예제 #3
0
  void QpToImplicit::init() {
    // Call the base class initializer
    ImplicitFunctionInternal::init();

    // Free variable in the NLP
    MX u = MX::sym("u", input(iin_).sparsity());

    // So that we can pass it on to createParent
    std::vector<Sparsity> sps;
    for (int i=0; i<getNumInputs(); ++i)
      if (i!=iin_) sps.push_back(input(i).sparsity());

    // u groups all parameters in an MX
    std::vector< MX > inputs;
    MX p = createParent(sps, inputs);

    // Dummy NLP objective
    MX nlp_f = 0;

    // NLP constraints
    std::vector< MX > args_call(getNumInputs());
    args_call[iin_] = u;
    for (int i=0, i2=0; i<getNumInputs(); ++i)
      if (i!=iin_) args_call[i] = inputs[i2++];
    MX nlp_g = f_.call(args_call).at(iout_);

    // We're going to use two-argument objective and constraints to allow the use of parameters
    MXFunction nlp(nlpIn("x", u, "p", p), nlpOut("f", nlp_f, "g", nlp_g));

    // Create an NlpSolver instance
    solver_ = NlpSolver(getOption(solvername()), nlp);
    if (hasSetOption(optionsname())) solver_.setOption(getOption(optionsname()));
    solver_.init();
  }
예제 #4
0
int FileMgr::createPathAndFile(const char *fName) {
	int fd;
	
	fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
	if (fd < 1) {
		createParent(fName);
		fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
	}
	return fd;
}
예제 #5
0
파일: filemgr.cpp 프로젝트: swordxx/swordxx
int FileMgr::createParent(NormalizedPath const & path) {
    NormalizedPath const buf(path.getParentDirectory());

    int retCode = 0;
    if (!buf.empty()) {
        if (::access(buf.c_str(), W_OK)) {  // not exists with write access?
            if ((retCode = ::mkdir(buf.c_str()
#ifndef WIN32
                    , 0755
#endif
                    ))) {
                createParent(buf.c_str());
                retCode = ::mkdir(buf.c_str()
#ifndef WIN32
                    , 0755
#endif
                    );
            }
        }
    }
    else retCode = -1;
    return retCode;
}