Пример #1
0
/*
 * NAME:	P->rename()
 * DESCRIPTION:	rename a file
 */
int P_rename(const char *from, const char *to)
{
    char buf1[STRINGSZ], buf2[STRINGSZ];

    if (path_file(buf1, from) == (char *) NULL ||
	path_file(buf2, to) == (char *) NULL) {
	return -1;
    }
    return rename(buf1, buf2);	/* has no underscore for some reason */
}
Пример #2
0
	//写严重错误信息
	void CLogger::TraceFatal(const char *lpcszFormat, ...)
	{
		//判断当前的写日志级别
		if (EnumLogLevel::LogLevel_Fatal > m_nLogLevel)
			return;
		string strResult;
		if (NULL != lpcszFormat)
		{
			va_list marker = NULL;
			va_start(marker, lpcszFormat); //初始化变量参数
			size_t nLength = _vscprintf(lpcszFormat, marker) + 1; //获取格式化字符串长度
			std::vector<char> vBuffer(nLength, '\0'); //创建用于存储格式化字符串的字符数组
			int nWritten = _vsnprintf_s(&vBuffer[0], vBuffer.size(), nLength, lpcszFormat, marker);
			if (nWritten > 0)
			{
				strResult = &vBuffer[0];
			}
			va_end(marker); //重置变量参数
		}
		if (strResult.empty())
		{
			return;
		}
		string strFileLine = FormatString("%s:%d\t", path_file(__FILE__,'\\'), __LINE__);
		string strLog = strFatalPrefix;
		strLog.append(GetTime()).append(strFileLine).append(strResult);

		//写日志文件
		Trace(strLog);
	}
Пример #3
0
void OSGViewerWidget::savePOVRayAnimation(void)
{
  IntParameter frame_numer("Frame Number", "Frame Number", 128, 4, 4096);
  ParameterDialog parameter_dialog(std::string(className())+" Parameters", MainWindow::getInstance());
  parameter_dialog.addParameter(&frame_numer);
  if (parameter_dialog.exec() != QDialog::Accepted)
    return;

  QString folder = QFileDialog::getExistingDirectory(MainWindow::getInstance(),
    tr("Save POV-Ray Files"), MainWindow::getInstance()->getWorkspace());

  if (folder.isEmpty())
    return;

  osgDB::ifstream path_file((MainWindow::getInstance()->getWorkspace().toStdString()+"/camera.path").c_str());
  if (!path_file.good())
    return;

  osg::ref_ptr<osg::AnimationPath> anmation_path(new osg::AnimationPath);
  anmation_path->read(path_file);

  QMutexLocker locker(&mutex_);
  PovRayVisitor povray_visitor(this);
  scene_root_->accept(povray_visitor);
  locker.unlock();

  povray_visitor.save(folder, anmation_path.get(), (int)(frame_numer));

  MainWindow::getInstance()->updateStatusMessage("POV-Ray animation saved!");

  return;
}
Пример #4
0
/*
 * NAME:	P->open()
 * DESCRIPTION:	open a file
 */
int P_open(const char *file, int flags, int mode)
{
    char buf[STRINGSZ];

    if (path_file(buf, file) == (char *) NULL) {
	return -1;
    }
    return _open(buf, flags, mode);
}
Пример #5
0
/*
 * NAME:	P_access()
 * DESCRIPTION:	check access on a file
 */
int P_access(const char *path, int mode)
{
    char buf[STRINGSZ];

    if (path_file(buf, path) == (char *) NULL) {
	return -1;
    }
    return _access(buf, mode);
}
Пример #6
0
/*
 * NAME:	P->stat()
 * DESCRIPTION:	get information about a file
 */
int P_stat(const char *path, struct stat *sb)
{
    char buf[STRINGSZ];

    if (path_file(buf, path) == (char *) NULL) {
	return -1;
    }
    return _stat(buf, (struct _stat *) sb);
}
Пример #7
0
/*
 * NAME:	P_rmdir()
 * DESCRIPTION:	remove an empty directory
 */
int P_rmdir(const char *path)
{
    char buf[STRINGSZ];

    if (path_file(buf, path) == (char *) NULL) {
	return -1;
    }

    return _rmdir(buf);
}
Пример #8
0
/*
 * NAME:	P->unlink()
 * DESCRIPTION:	remove a file (but not a directory)
 */
int P_unlink(char *path)
{
    char buf[STRINGSZ];

    if (path_file(buf, path) == (char *) NULL) {
	return -1;
    }

    return _unlink(buf);
}
Пример #9
0
/*
 * NAME:	P->opendir()
 * DESCRIPTION:	open a directory
 */
bool P_opendir(const char *dir)
{
    char path[_MAX_PATH + 2];

    if (path_file(path, dir) == (char *) NULL) {
	return FALSE;
    }
    strcat(path, "\\*");
    d = _findfirst(path, &fdata);
    return (d != -1);
}
Пример #10
0
/*
 * NAME:	P->chdir()
 * DESCRIPTION:	change the current directory (and drive)
 */
int P_chdir(const char *dir)
{
    char buf[STRINGSZ];

    if (path_file(buf, dir) == (char *) NULL || _chdir(buf) < 0) {
	return -1;
    }
    if (buf[1] == ':' && _chdrive(toupper(buf[0]) - 'A' + 1) < 0) {
	return -1;
    }
    return 0;
}
Пример #11
0
/*
 * NAME:	P->mkdir()
 * DESCRIPTION:	create a directory
 */
int P_mkdir(const char *path, int mode)
{
    char buf[STRINGSZ];

    UNREFERENCED_PARAMETER(mode);

    if (path_file(buf, path) == (char *) NULL) {
	return -1;
    }

    return _mkdir(buf);
}
Пример #12
0
nomask object compile_object(string file)
{
   string name, server;
   string *tmp;

   if (file_size(file) != -1) return 0;

   tmp = path_file(file);
   server = tmp[0] + "/" + VSERVER_NAME;
   if (file_size(server + ".c") == -1)
      server = DEFAULT_VSERVER;
   return (object)call_other(server,"compile_object",file);
}
Пример #13
0
void		insert_sort(char *da_file, t_dlist **files, char *path)
{
	int				len;
	t_dlist			*nav;
	t_file			data;

	len = ft_dlstlen(*files);
	nav = ft_dlstlast(*files);
	data.filename = ft_strdup(da_file);
	if (path == NULL)
		data.path = data.filename;
	else
		data.path = path_file(path, da_file, 0);
	if (lstat(data.path, &data.sb) == -1)
		error(BAD_PATH, data.path);
	while (len > 0)
	{
		if (ft_strcmp(((t_file *)nav->content)->filename, da_file) < 0)
			break ;
		nav = nav->before;
		len--;
	}
	ft_dlstadd_i(files, ft_dlstnew(&data, sizeof(t_file)), len);
}