Exemplo n.º 1
0
	xgc_bool InitException()
	{
		# ifndef _DEBUG
		g_exception_filter = ::SetUnhandledExceptionFilter( exception_filter );
		g_exception_translator = ::_set_se_translator( exception_translate );
		# endif

		get_absolute_path( g_exception_log, sizeof( g_exception_log ), "%s", "exception" );
		get_absolute_path( g_exception_ext, sizeof( g_exception_ext ), "%s", "log" );
		get_absolute_path( g_exception_dmp, sizeof( g_exception_dmp ), "%s", "dmp" );

		// 获取进程句柄
		hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId() );
		if( hProcess == NULL )
		{
			DBG_TIP( "OpenProcess failed. err = %u", GetLastError() );
			return false;
		}

		// If the symbol engine is not initialized, do it now.
		if( !SymInitialize( hProcess, NULL, TRUE ) )
		{
			DBG_TIP( "SymInitialize failed. err = %u", GetLastError() );
			return false;
		}

		DumpStackFrame();
		SYS_TIP( "异常报告生成!" );
		return true;
	}
Exemplo n.º 2
0
static void test_getChildInDirectory_FindFromFileAndDir_FileExists() {
    before();
    GNode *tree = single_folder(TRUE, TRUE);

// THIS IS THE STRUCTURE:
//
// test-dir (7 children)
// ├─ .apa.png
// ├─ .depa.gif
// ├─ bepa.png
// ├─ cepa.jpg
// ├─ epa.png
// ├─┬dir_one (3 children)
// │ ├─ .three.png
// │ ├─ two.jpg
// │ └─┬.secrets (1 children)
// │   └─ img.jpg
// └─┬dir_two (7 children)
//   ├─ apa.png
//   ├─ bepa.png
//   ├─ cepa.png
//   ├─┬sub_dir_four (2 children)
//   │ ├──subsub (0 children)
//   │ └──subsub2 (0 children)
//   ├─┬sub_dir_one (3 children)
//   │ ├─ img0.png
//   │ ├─ img1.png
//   │ └─ img2.png
//   ├──sub_dir_three (0 children)
//   └─┬sub_dir_two (3 children)
//     ├─ img0.png
//     ├─ img1.png
//     ├─ img2.png
//     └─ img3.png

    char *path0 = get_absolute_path(testdir_path, "/bepa.png");
    char *path1 = get_absolute_path(testdir_path, "/dir_two");
    char *path2 = get_absolute_path(testdir_path, "/dir_two/bepa.png");

    GNode *child0 = get_child_in_directory(tree, path0);
    GNode *child1 = g_node_last_child(get_root_node(tree));
    assert_child_is_equal("Get child in directory ─ Find bepa.png", child0, path0);
    assert_child_is_equal("Get child in directory ─ Last child is dir_two", child1, path1);

    GNode *child2 = get_child_in_directory(child0, path2);
    GNode *child3 = get_child_in_directory(child1, path2);

    assert_child_is_equal("Get child in directory ─ From file ─ File exists", child2, path2);
    assert_child_is_equal("Get child in directory ─ From subdir ─ File exists", child3, path2);

    free(path0);
    free(path1);
    free(path2);
    free_whole_tree(tree);
    after();
}
Exemplo n.º 3
0
static void test_getChildInDirectory_DirectoryIsEmpty() {
    before();
    GNode *tree = single_folder(TRUE, TRUE);

// THIS IS THE STRUCTURE:
//
// test-dir (7 children)
// ├─ .apa.png
// ├─ .depa.gif
// ├─ bepa.png
// ├─ cepa.jpg
// ├─ epa.png
// ├─┬dir_one (3 children)
// │ ├─ .three.png
// │ ├─ two.jpg
// │ └─┬.secrets (1 children)
// │   └─ img.jpg
// └─┬dir_two (7 children)
//   ├─ apa.png
//   ├─ bepa.png
//   ├─ cepa.png
//   ├─┬sub_dir_four (2 children)
//   │ ├──subsub (0 children)
//   │ └──subsub2 (0 children)
//   ├─┬sub_dir_one (3 children)
//   │ ├─ img0.png
//   │ ├─ img1.png
//   │ └─ img2.png
//   ├──sub_dir_three (0 children)
//   └─┬sub_dir_two (3 children)
//     ├─ img0.png
//     ├─ img1.png
//     ├─ img2.png
//     └─ img3.png

    char *path0 = get_absolute_path(testdir_path, "/dir_two/sub_dir_four/subsub");
    char *path1 = get_absolute_path(testdir_path, "/dir_two/sub_dir_four/subsub/apa.jpg");

    GNode *child = get_root_node(tree);
    child = g_node_last_child(child);
    child = g_node_first_child(child);
    child = g_node_next_sibling(child);
    child = g_node_next_sibling(child);
    child = g_node_next_sibling(child);
    child = g_node_first_child(child);
    assert_child_is_equal("Get child in directory ─ Last child is subsub", child, path0);

    child = get_child_in_directory(child, path1);

    assert_tree_is_null("Get child in directory ─ Directory is empty", child);

    free(path0);
    free(path1);
    free_whole_tree(tree);
    after();
}
/**
 * @brief 执行cat命令 
 * @details 输出指定文件的全部内容
 * @param[in] path 指定文件的路径
 * @return 成功返回true,失败返回false
 */
bool cat( const char * path )
{
	char absolute_path[MAX_PATH];
	assert(path != NULL);
	get_absolute_path(absolute_path, path);
	return output_file_data(absolute_path);
}
void
dmz::RenderModuleCoreOSGBasic::_init (Config &local, Config &global) {

   const String UpStr = config_to_string ("osg-up.value", local, "y").to_lower ();
   if (UpStr == "y") { set_osg_y_up (); _log.info << "OSG render Y is up." << endl; }
   else if (UpStr == "z") { set_osg_z_up (); _log.info << "OSG render Z is up" << endl; }
   else {

      _log.warn << "Unknown osg up type: " << UpStr << ". Defaulting to Y up." << endl;
   }

   Config pluginList;

   if (local.lookup_all_config ("plugin-list.plugin", pluginList)) {

      RuntimeContext *context (get_plugin_runtime_context ());

      if (dmz::load_plugins (context, pluginList, local, global, _extensions, &_log)) {

         _extensions.discover_plugins ();
         _extensions.discover_external_plugin (this);
      }
   }

   osgDB::Registry *reg = osgDB::Registry::instance ();
   Config pathList;

   if (reg && local.lookup_all_config ("loader.path", pathList)) {

      osgDB::FilePathList &fpl = reg->getLibraryFilePathList ();

      ConfigIterator it;
      Config path;

      while (pathList.get_next_config (it, path)) {

         String pathStr = config_to_string ("value", path);

         if (get_absolute_path (pathStr, pathStr)) {

            fpl.push_back (pathStr.get_buffer ());
         }
      }

   }

   if(reg) {

      reg->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
   }

   _defaultHandle = activate_default_object_attribute (
      ObjectDestroyMask | ObjectPositionMask | ObjectScaleMask | ObjectOrientationMask);

   _bvrHandle = config_to_named_handle (
      "bounding-volume-radius-attribute.name",
      local,
      ObjectAttributeBoundingVolumeRaidusName,
      get_plugin_runtime_context ());
}
/* adds a watchmail option */
void
watchmail_add(char* to_add)
{
    struct maillist *tmp = find_mail_in_watch(to_add);
    if (tmp) {
        printf("YuqiShell: watchmail: %s is already in watch!\n");
        return;
    }

    char filename[128];
    strcpy(filename, get_absolute_path(to_add));
    printf("Filename to watch is %s\n");
    if (access(filename, R_OK) == -1) {
        printf("YuqiShell: matchmail: error: %s\n", strerror(errno));
        return;
    }

    tmp = (struct maillist*)malloc(sizeof(struct maillist));
    tmp->next = mailhead;
    mailhead = tmp;
    strcpy (tmp->filename, filename);
    struct stat st;
    stat(filename, &st);
    tmp->st_size = st.st_size;
    pthread_create(&(tmp->tid), NULL, mail_daemon, tmp);
}
Exemplo n.º 7
0
libusb_device *get_usb_device(libusb_context *ctx, const char *path)
{
	libusb_device **list;
	libusb_device *dev;
	ssize_t num_devs, i;
	char device_path[PATH_MAX + 1];
	char absolute_path[PATH_MAX + 1];

	readlink_recursive(path, device_path, sizeof(device_path));
	get_absolute_path(device_path, absolute_path, sizeof(absolute_path));

	dev = NULL;
	num_devs = libusb_get_device_list(ctx, &list);

	for (i = 0; i < num_devs; ++i) {
		uint8_t bnum = libusb_get_bus_number(list[i]);
		uint8_t dnum = libusb_get_device_address(list[i]);

		snprintf(device_path, sizeof(device_path), "%s/%03u/%03u",
			 devbususb, bnum, dnum);
		if (!strcmp(device_path, absolute_path)) {
			dev = list[i];
			break;
		}
	}

	libusb_free_device_list(list, 0);
	return dev;
}
Exemplo n.º 8
0
// AudioModule Interface
dmz::Handle
dmz::AudioModuleFMOD::create_sound (const String &FileName) {

   Handle result (0);
   String absPath;

   if (_system) {

      // Convert to absolute file path
      Boolean validPath = get_absolute_path (FileName, absPath);

      if (validPath) {

         SoundStruct *soundData = _soundNameTable.lookup (absPath);

         if (soundData) {

            result = soundData->get_handle ();
         }
         else {

            FMOD::Sound *newSound (0);

            FMOD_RESULT fmodResult = _system->createSound (
               absPath.get_buffer (),
               FMOD_3D,
               0,
               &newSound);

            String loadingErrorHeader ("Loading Sound '");
            loadingErrorHeader << absPath << "'";

            if (_error_check (loadingErrorHeader, fmodResult)) {

               SoundStruct *newSoundData = new SoundStruct (
                  absPath,
                  newSound,
                  _soundHandleTable,
                  _soundNameTable,
                  get_plugin_runtime_context ());

               if (newSoundData && _soundNameTable.store (absPath, newSoundData)) {

                  Handle newHandle = newSoundData->get_handle ();

                  if (newHandle && _soundHandleTable.store (newHandle, newSoundData)) {

                     _log.info << "Sound file '" << absPath << "' Loaded" << endl;
                     result = newHandle;
                  }
               }
               else if (newSoundData) { newSoundData->unref (); }
            }
         }
      }
   }

   return result;
}
static int sreadahead_prof_RUN(struct file *filp, size_t len, loff_t pos)
{
	int i;
	struct sreadahead_profdata data;
	memset(&data, 0x00, sizeof(struct sreadahead_profdata));
	data.len = (long long)len;
	data.pos[0] = pos;
	data.pos[1] = 0;
	data.procname[0] = '\0';
	get_task_comm(data.procname, current);

	if (get_absolute_path(data.name, FILE_PATHLEN + FILE_NAMELEN, filp) < 0)
		return -1;
	strcat(data.name, filp->f_path.dentry->d_name.name);

	mutex_lock(&prof_buf.ulock);

	/* vfree called or profiling is already done */
	if (prof_buf.data == NULL || prof_buf.state != PROF_RUN) {
		mutex_unlock(&prof_buf.ulock);
		return -1;
	}

	for (i = 0; i < prof_buf.file_cnt; ++i) {
		if (strncmp(prof_buf.data[i].name, data.name, FILE_PATHLEN + FILE_NAMELEN) == 0) {
			break;
		}
	}
	/* add a new entry */
	if (i == prof_buf.file_cnt && i < PROF_BUF_SIZE) {
		strncpy(prof_buf.data[i].procname, data.procname, PROC_NAMELEN);
		prof_buf.data[i].procname[PROC_NAMELEN - 1] = '\0';
		strncpy(prof_buf.data[i].name, data.name, FILE_PATHLEN + FILE_NAMELEN);
		prof_buf.data[i].name[FILE_PATHLEN + FILE_NAMELEN - 1] = '\0';
		prof_buf.data[i].pos[0] = prof_buf.data[i].pos[1] = ALIGNPAGECACHE(data.pos[0]);
		prof_buf.data[i].pos[1] += E_ALIGNPAGECACHE((long long)data.len);
		prof_buf.data[i].len = prof_buf.data[i].pos[1] - prof_buf.data[i].pos[0];
		prof_buf.file_cnt++;

		_DBG("New Entry - %s:%lld:%lld#%s -- cnt:%d",
				prof_buf.data[i].name,
				prof_buf.data[i].pos[0],
				prof_buf.data[i].len,
				prof_buf.data[i].procname,
				prof_buf.file_cnt);
	}

	if (prof_buf.file_cnt >= PROF_BUF_SIZE) {
		_DBG("PROF_DONE by kernel(file_cnt) & del timer");
		prof_buf.state = PROF_DONE;
		del_timer(&prof_buf.timer);
	}

	mutex_unlock(&prof_buf.ulock);

	return 0;
}
Exemplo n.º 10
0
bool DiskFilesystem::is_file(const char* path)
{
	CE_ASSERT_NOT_NULL(path);

	TempAllocator256 alloc;
	DynamicString abs_path(alloc);
	get_absolute_path(path, abs_path);

	return os::is_file(abs_path.c_str());
}
Exemplo n.º 11
0
File* DiskFilesystem::open(const char* path, FileOpenMode mode)
{
	CE_ASSERT_NOT_NULL(path);

	TempAllocator256 alloc;
	DynamicString abs_path(alloc);
	get_absolute_path(path, abs_path);

	return CE_NEW(default_allocator(), DiskFile)(mode, abs_path.c_str());
}
Exemplo n.º 12
0
void DiskFilesystem::list_files(const char* path, Vector<DynamicString>& files)
{
	CE_ASSERT_NOT_NULL(path);

	TempAllocator256 alloc;
	DynamicString abs_path(alloc);
	get_absolute_path(path, abs_path);

	os::list_files(abs_path.c_str(), files);
}
Exemplo n.º 13
0
void DiskFilesystem::delete_directory(const char* path)
{
	CE_ASSERT_NOT_NULL(path);

	TempAllocator256 alloc;
	DynamicString abs_path(alloc);
	get_absolute_path(path, abs_path);

	os::delete_directory(abs_path.c_str());
}
Exemplo n.º 14
0
static void test_getChildInDirectory_DirectoryIsNull() {
    before();
    char *path0 = get_absolute_path(testdir_path, "/dir_two/sub_dir_four/subsub/apa.jpg");

    GNode *child = get_child_in_directory(NULL, path0);

    assert_tree_is_null("Get child in directory ─ Directory is empty", child);

    free(path0);
    after();
}
Exemplo n.º 15
0
int main( int argc, char* argv[] )
{
	#ifdef _WINDOWS
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	#endif

	char conf_path[1024] = { 0 };
	if( xgc_nullptr == get_absolute_path( conf_path, "../client.ini" ) )
	{
		fprintf( stderr, "format conf path error %s", conf_path );
		return -1;
	}

	ini_reader ini;
	if( false == ini.load( conf_path ) )
	{
		fprintf( stderr, "conf load error %s", conf_path );
		return -1;
	}

	auto addr = ini.get_item_value( "Client", "Host", "127.0.0.1" );
	auto port = ini.get_item_value( "Client", "Port", 50001 );
	auto root = ini.get_item_value( "Client", "Root", xgc_nullptr );
	XGC_ASSERT_RETURN( root, -1 );

	make_dirs( root );
	strcpy_s( root_path, root );

	if( false == net::CreateNetwork( 1 ) )
		return -1;

	net::connect_options opt;
	memset( &opt, 0, sizeof( opt ) );
	opt.is_async = false;
	opt.is_reconnect_passive = false;
	opt.is_reconnect_timeout = false;
	opt.recv_buffer_size = 64 * 1024;
	opt.send_buffer_size = 64 * 1024;

	opt.recv_packet_max = 64 * 1024;
	opt.recv_packet_max = 64 * 1024;

	opt.timeout = 1000;

	net::Connect( addr, port, XGC_NEW CNetSession(), &opt );
	while( running )
	{
		if( net::ProcessNetEvent( 100 ) == 100 )
			std::this_thread::sleep_for( std::chrono::milliseconds(1) );
	}
	net::DestroyNetwork();

	return 0;
}
Exemplo n.º 16
0
bool OEFind::get_conf_dir()
{
	char filename[1024];
	char dir[1024];

	get_exe_path(filename, 1024);
	get_file_dir(dir, filename, 1024);
	if (!get_absolute_path(conf_dir, "../conf/OEFind/", dir))
		return false;

	return true;
}
Exemplo n.º 17
0
int open(const char *pathname, int flags) {
	int id;
	if (pathname[0] != '/' && pathname[0] != '$') {
		char * absolutepath = get_absolute_path(pathname);
		syscall(SYS_OPEN,(uint32_t) &id,(uint32_t) absolutepath,(uint32_t) flags);
		free(absolutepath);
	} else {
		syscall(SYS_OPEN,(uint32_t) &id,(uint32_t) pathname,(uint32_t) flags);
	}
	
	return id;
}
/**
 * @brief 执行rm命令 
 * @details 删除指定文件
 * @param[in] remove_paths 需要删除的文件的路径
 * @param[in] recursive    是否递归删除
 * @param[in] force        是否强行删除只读文件
 * @return 成功返回true,失败返回false
 */
bool rm( const char * const * const remove_paths, bool recursive, bool force )
{
	char absolute_path[MAX_PATH];
	const char * const * p = NULL;

	assert(remove_paths != NULL);
	for ( p = remove_paths; (*p) != NULL; ++ p )
	{
		get_absolute_path(absolute_path, *p);
		if ( !remove_file(absolute_path) )
			fprintf(stderr, "rm: cannot remove ‘%s’: No such file or directory\n", (*p));
	}
	return true;
}
/* finds whether a mail is already in watch */
struct maillist *
find_mail_in_watch(char *to_find)
{
    struct maillist *tmp = mailhead;
    struct maillist *to_return = NULL;
    char filename[128];
    strcpy(filename, get_absolute_path(to_find));
    while (tmp) {
        if (strcmp(tmp->filename, filename) == 0) {
            to_return = tmp;
            break;
        }
        tmp = tmp->next;
    }
    return to_return;
}
Exemplo n.º 20
0
// Save history to file
void wbem::support::SupportDataServiceFactory::exportToUri(const std::string exportUri)
const throw (framework::Exception)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
	COMMON_PATH absPath;
	if (get_absolute_path(exportUri.c_str(), exportUri.length() + 1, absPath) != COMMON_SUCCESS)
	{
		throw framework::ExceptionBadParameter(exportUri.c_str());
	}

	int rc;
	if ((rc = m_GatherSupportProvider(absPath, strlen(absPath))) != NVM_SUCCESS)
	{
		throw exception::NvmExceptionLibError(rc);
	}
}
/**
 * @brief 执行ls命令 
 * @details 列出指定目录的多个文件
 * @param[in] all        是否输出全部文件,包括隐藏文件,以及.和..
 * @param[in] almost_all 是否“几乎全部”输出,包括隐藏文件,不包括.和..
 * @param[in] long_list  是否按长列表方式输出
 * @param[in] list_path  需要列出文件的目录数组
 * @return 成功返回true,失败返回false
 */
bool ls( bool all, bool almost_all, bool long_list, const char * const * const list_path )
{
	char absolute_path[MAX_PATH];
	const char * const * p = NULL;

	if ( list_path == NULL )
		output_files(current_path, all, almost_all, long_list);
	else
	{
		for ( p = list_path; (*p) != NULL; ++ p )
		{
			get_absolute_path(absolute_path, *p);
			output_files(absolute_path, all, almost_all, long_list);
		}
	}
	return true;
}
Exemplo n.º 22
0
/* 1 if exists, 0 if doesn't exist */
int check_file_exists(char *path) {
    /* Don't accept paths that go up in the directory tree */
    int ret;
    struct stat buf;
    char *full_dir;

    full_dir = get_absolute_path(path);
    if (!full_dir)
        return(0);

    ret = stat(full_dir, &buf);
    free(full_dir);
    if (!ret)
        return(1);
    else
        return(0);
}
Exemplo n.º 23
0
static void test_getChildInDirectory_FindRoot() {
    before();
    GNode *tree = single_folder(TRUE, TRUE);

// THIS IS THE STRUCTURE:
//
// test-dir (7 children)
// ├─ .apa.png
// ├─ .depa.gif
// ├─ bepa.png
// ├─ cepa.jpg
// ├─ epa.png
// ├─┬dir_one (3 children)
// │ ├─ .three.png
// │ ├─ two.jpg
// │ └─┬.secrets (1 children)
// │   └─ img.jpg
// └─┬dir_two (7 children)
//   ├─ apa.png
//   ├─ bepa.png
//   ├─ cepa.png
//   ├─┬sub_dir_four (2 children)
//   │ ├──subsub (0 children)
//   │ └──subsub2 (0 children)
//   ├─┬sub_dir_one (3 children)
//   │ ├─ img0.png
//   │ ├─ img1.png
//   │ └─ img2.png
//   ├──sub_dir_three (0 children)
//   └─┬sub_dir_two (3 children)
//     ├─ img0.png
//     ├─ img1.png
//     ├─ img2.png
//     └─ img3.png

    char *path0 = get_absolute_path(testdir_path, "");

    GNode *child = get_child_in_directory(tree, path0);

    assert_child_is_equal("Get child in directory ─ Find root", child, path0);

    free(path0);
    free_whole_tree(tree);
    after();
}
/**
 * @brief 执行cd命令
 * @details 把当前目录切换到指定目录
 * @param[in] path 需要切换到的目录
 * @return 成功返回true,失败返回false
 */
bool cd(const char * path)
{
	char absolute_path[MAX_PATH];
	assert(path != NULL);
	get_absolute_path(absolute_path, path);

	if ( exsit_dir_path(absolute_path) )
	{
		strncpy(current_path, absolute_path, sizeof(current_path));
		current_path[sizeof(current_path) - 1] = '\0';
		return true;
	}
	else
	{
		sprintf(lastError, "cd: %s: No such directory", path);
		return false;
	}
}
Exemplo n.º 25
0
struct usb_device *get_usb_device(const char *path)
{
	struct usb_bus *bus;
	struct usb_device *dev;
	char device_path[PATH_MAX + 1];
	char absolute_path[PATH_MAX + 1];

	readlink_recursive(path, device_path, sizeof(device_path));
	get_absolute_path(device_path, absolute_path, sizeof(absolute_path));
	
	for (bus = usb_busses; bus; bus = bus->next) {
        	for (dev = bus->devices; dev; dev = dev->next) {
			snprintf(device_path, sizeof(device_path), "%s/%s/%s", devbususb, bus->dirname, dev->filename);
			if (!strcmp(device_path, absolute_path))
				return dev;
		}				
        }			
	return NULL;
}	
Exemplo n.º 26
0
/*!

\brief Validates all paths.
\ingroup System
\details Defined in dmzSystemFile.h.
\param[in] Container dmz::StringContainer of the paths to be validated.
\return Returns a dmz::StringContainer with the absolute path for all valid
paths in \a Container.

*/
dmz::StringContainer
dmz::validate_path_container (const StringContainer &Container) {

    StringContainer result;

    String path;

    Boolean found (Container.get_first (path));

    while (found) {

        const String CleanPath (format_path (path));

        if (get_absolute_path (CleanPath, path)) {
            result.add (path);
        }

        found = Container.get_next (path);
    }

    return result;
}
Exemplo n.º 27
0
static void test_addNodeInTree_DuplicateNode() {
    before();
    char *path = get_absolute_path(testdir_path, "/cepa.jpg");

    VnrFile *vnrfile = vnr_file_create_new(path, "cepa.jpg", FALSE);
    GNode *node = g_node_new(vnrfile);

    GNode *tree = get_tree(SINGLE_FILE, FALSE, FALSE);
    tree = get_root_node(tree);

    add_node_in_tree(tree, node);
    char* expected = KWHT TESTDIRNAME RESET " (3 children)\n\
├─ bepa.png\n\
├─ cepa.jpg\n\
└─ epa.png\n\
";

    assert_equals("Add node in tree ─ Duplicate node: F ─ Recursive: F", expected, print_and_free_tree(tree));

    free(path);
    free_whole_tree(node);
    after();
}
Exemplo n.º 28
0
void command_line (gint argc, gchar *argv[])
{
  if (argc >= 2)
    {
      gint i;
      gboolean FirstTime = TRUE;
      
      for (i = 1; i < argc; i++)
	{
	  struct stat Stats;
	  gchar *BaseName;
	  gchar *FileName;
	  gint CurrentPage;

	  if (stat (argv[i], &Stats) != -1)
	    if ((Stats.st_mode & S_IFMT) == S_IFDIR) continue;
	  if (!strcmp ((BaseName = str_get_last_part
			(argv[i], PATH_SEP, TRUE)), "")) continue;
	  if ((!strcmp (argv[i], "--")) && (FirstTime == TRUE))
	    {
	      FirstTime = FALSE;
	      continue;
	    }
	  FileName = get_absolute_path (argv[i]);
	  if (stat (argv[i], &Stats) != -1) put_recent_file (FileName);
	  add_page_in_notebook (GTK_NOTEBOOK(MainNotebook), FileName);
	  CurrentPage = gtk_notebook_get_current_page
	    (GTK_NOTEBOOK(MainNotebook));
	  open_file_in_editor(GTK_WIDGET(FPROPS(CurrentPage, Text)), FileName);
	  g_free (BaseName);
	  g_free (FileName);
	  FPROPS(CurrentPage, Changed[1]) =
	    gtk_signal_connect (GTK_OBJECT(FPROPS(CurrentPage, Text)),
				"changed", (GtkSignalFunc) set_changed, NULL);
	}
    }
}
Exemplo n.º 29
0
static error_t
arequal_parse_opts (int key, char *arg, struct argp_state *_state)
{
        switch (key) {
        case 'i':
        {
                arequal_config.directories_ignored++;
                add_to_list (arg);
        }
        break;
        case 'p':
        {
                if (arg[0] == '/')
                        strcpy (arequal_config.test_directory, arg);
                else
                        get_absolute_path (arequal_config.test_directory, arg);

                if (arequal_config.test_directory
                    [strlen(arequal_config.test_directory) - 1] == '/')
                        arequal_config.test_directory
                                [strlen(arequal_config.test_directory) - 1] = '\0';
        }
        break;

        case ARGP_KEY_NO_ARGS:
                break;
        case ARGP_KEY_ARG:
                break;
        case ARGP_KEY_END:
                if (_state->argc == 1) {
                       argp_usage (_state);
                }

        }

        return 0;
}
Exemplo n.º 30
0
/*!

\brief Finds file on file system.
\ingroup System
\details Defined in dmzSystemFile.h.
This function takes three steps to locate the file. First it attempts to validate the
file as it is passed in. If the file is not found. All leading path information is
stripped from the file and then each path in the StringContainer is used to try
and locate the file. If the file is not found, each path in the StringContainer is
searched with out the leading path information stripped from the \a FileName.
\param[in] Container StringContainer with list of paths to use in the file search.
\param[in] FileName String containing the name of the file to search for.
\param[out] foundFile String containing the absolute path to the found file.
\return Returns dmz::True if the file is found.

*/
dmz::Boolean
dmz::find_file (
    const StringContainer &Container,
    const String &FileName,
    String &foundFile) {

    Boolean result (False);

    if (is_valid_path (FileName)) {
        result = get_absolute_path (FileName, foundFile);
    }

    if (!result) {

        String path, file, ext;
        split_path_file_ext (FileName, path, file, ext);

        if (file) {

            file << ext;

            Boolean done (!Container.get_first (path));

            while (!done) {

                const String CleanPath (format_path (path + "/" + file));

                if (is_valid_path (CleanPath)) {

                    result = get_absolute_path (CleanPath, foundFile);
                    done = True;
                }
                else {
                    done = !Container.get_next (path);
                }
            }
        }
    }

    if (!result) {

        String path;

        Boolean done (!Container.get_first (path));

        while (!done) {

            const String CleanPath (format_path (path + "/" + FileName));

            if (is_valid_path (CleanPath)) {

                result = get_absolute_path (CleanPath, foundFile);
                done = True;
            }
            else {
                done = !Container.get_next (path);
            }
        }
    }

    return result;
}