当前位置: 首页>>代码示例>>C++>>正文


C++ FXString::before方法代码示例

本文整理汇总了C++中FXString::before方法的典型用法代码示例。如果您正苦于以下问题:C++ FXString::before方法的具体用法?C++ FXString::before怎么用?C++ FXString::before使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FXString的用法示例。


在下文中一共展示了FXString::before方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: existCommand

// Check if the specified command can be found in exec path
FXbool existCommand(FXString cmd)
{
	struct stat linfo;

	// If first character is '/' then cmd is an absolute path
	if (cmd[0]==PATHSEPCHAR)
	{
		// Check if command exists
		if (!cmd.empty() && (lstatrep(cmd.text(),&linfo)==0))
			return TRUE;	
	}
	
	// Simple command name or relative path
	else
	{
		// Get exec path
		FXString execpath=FXSystem::getExecPath();
		
		if(execpath != "")
		{
			FXString path;

			for(FXint i=0;;i++)
			{
				// Obtain path component
				path=execpath.section(':',i);
				if(path=="")
					break;
				
				// Form command absolute path
				path += PATHSEPSTRING + cmd.before(' ');			
				
				// Check if command exists
				if (!path.empty() && (lstatrep(path.text(),&linfo)==0))
					return TRUE;
			}
		}
    }
	return FALSE;
}
开发者ID:tindzk,项目名称:Xfe,代码行数:41,代码来源:xfeutils.cpp

示例2: throw

FXString
MFXUtils::getDocumentName(const FXString &filename) throw() {
    FXString file = FXPath::name(filename);
    return file.before('.');
}
开发者ID:NeziheSozen,项目名称:sumo,代码行数:5,代码来源:MFXUtils.cpp

示例3: runcmd

// Launch a command and initiate a startup notification
int runcmd(FXString cmd, FXString cmdname, FXString dir, FXString startdir, FXbool usesn = true, FXString snexcepts = "")
{
    int ret;

    // Change to current directory
    ret = chdir(dir.text());
    if (ret < 0)
    {
        int errcode = errno;
        if (errcode)
        {
            fprintf(stderr, _("Error: Can't enter folder %s: %s"), dir.text(), strerror(errcode));
        }
        else
        {
            fprintf(stderr, _("Error: Can't enter folder %s"), dir.text());
        }

        return(-1);
    }

    // Get rid of possible command options
    cmdname = cmdname.before(' ');

    // Check if command is in the startup notification exception list
    FXbool startup_notify = true;
    if (snexcepts != "")
    {
        FXString entry;
        for (int i = 0; ; i++)
        {
            entry = snexcepts.section(':', i);
            if (streq(entry.text(), ""))
            {
                break;
            }
            if (streq(entry.text(), cmdname.text()))
            {
                startup_notify = false;
                break;
            }
        }
    }

    // Run command with startup notification
    if (usesn && startup_notify)
    {
        Display*           xdisplay;
        SnDisplay*         display;
        SnLauncherContext* context;
        Time               timestamp;

        // Open display
        xdisplay = XOpenDisplay(NULL);
        if (xdisplay == NULL)
        {
            fprintf(stderr, _("Error: Can't open display\n"));
            ret = chdir(startdir.text());
            if (ret < 0)
            {
                int errcode = errno;
                if (errcode)
                {
                    fprintf(stderr, _("Error: Can't enter folder %s: %s"), startdir.text(), strerror(errcode));
                }
                else
                {
                    fprintf(stderr, _("Error: Can't enter folder %s"), startdir.text());
                }
            }
            return(-1);
        }

        // Message displayed in the task bar (if any)
        FXString message;
        message.format(_("Start of %s"), cmdname.text());

        // Initiate launcher context
        display = sn_display_new(xdisplay, NULL, NULL);
        context = sn_launcher_context_new(display, DefaultScreen(xdisplay));
        sn_launcher_context_set_name(context, message.text());
        sn_launcher_context_set_binary_name(context, cmdname.text());
        sn_launcher_context_set_description(context, message.text());
        sn_launcher_context_set_icon_name(context, cmdname.text());
        timestamp = gettimestamp();
        sn_launcher_context_initiate(context, "Xfe", cmd.text(), timestamp);

        // Run command in background
        cmd += " &";

        static pid_t child_pid = 0;
        switch ((child_pid = fork()))
        {
        case -1:
            fprintf(stderr, _("Error: Fork failed: %s\n"), strerror(errno));
            break;

        case 0: // Child
            sn_launcher_context_setup_child_process(context);
//.........这里部分代码省略.........
开发者ID:paulmadore,项目名称:luckyde,代码行数:101,代码来源:startupnotification.cpp


注:本文中的FXString::before方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。