コード例 #1
0
ファイル: FileGrabber.cpp プロジェクト: calculous/metroscope
void FileGrabber::run()
{
    if (mCurrentFile != cEndOfDirectory)
    {
    	if (mFirstImage){
    		mFirstImage = false;
    	} else {
    		findNextFile();
			loadImage();

			while (!mImage && mCurrentFile != cEndOfDirectory){
				std::cout << "Error: " << mCurrentFile->path().string() << " is corrupted" << std::endl;
    			findNextFile();
				loadImage();
			}
    	}
    } else {
    	stop();
    }

    if (mCurrentFile == cEndOfDirectory) {
    	std::cout << "no Image left" << std::endl;
		cvReleaseImage(&mImage);
		mImage = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3);
		stop();
    }
}
コード例 #2
0
ファイル: OSUnix.cpp プロジェクト: mdaus/nitro
std::string sys::DirectoryUnix::findFirstFile(const std::string& dir)
{
    // First file is always . on Unix
    mDir = ::opendir(dir.c_str());
    if (mDir == NULL)
        return "";
    return findNextFile();
}
コード例 #3
0
ファイル: daemon.c プロジェクト: fbavaro56/iguanair
void setAlias(unsigned int id, const char *alias)
{
    /* find the alias and nuke it if it is a link to the name */
    DIR_HANDLE dir = NULL;
    char buffer[PATH_MAX], name[4];

    /* prepare the name string */
    sprintf(name, "%d", id);

    /* look through all symlinks in the directory and delete links to
       name */
    strcpy(buffer, IGSOCK_NAME);
    while((dir = findNextFile(dir, buffer)) != NULL)
    {
        char ptr[PATH_MAX], buf[PATH_MAX];
        int length;

        sprintf(buf, "%s%s", IGSOCK_NAME, buffer);
        length = readlink(buf, ptr, PATH_MAX - 1);
        if (length > 0)
        {
            ptr[length] = '\0';
            if (strcmp(name, ptr) == 0)
                unlink(buf);
        }
    }

    /* create a new symlink from alias to name */
    if (alias != NULL)
    {
        char path[PATH_MAX], *slash, *aliasCopy;
        struct stat st;

        aliasCopy = strdup(alias);
        while(1)
        {
            slash = strchr(aliasCopy, '/');
            if (slash == NULL)
                break;
            slash[0] = '|';
        }
        socketName(aliasCopy, path, PATH_MAX);
        free(aliasCopy);

        if (lstat(path, &st) == 0 && S_ISLNK(st.st_mode))
            unlink(path);
        symlink(name, path);
    }
}
コード例 #4
0
ファイル: VDirAdapter_Unix.cpp プロジェクト: asnwerear/Demo
	bool VDirAdapter_Unix::findNextFile()
	{
        if (NULL == m_pDir)
        {
            return false;
        }
        
        m_pDirent = readdir(m_pDir);
        if (m_pDirent != NULL && !isDirectory())
        {
            VString strName = m_pDirent->d_name;
            VString strExt;
            extractExt(strName, strExt);
            if (strExt != m_strExt && m_strExt != "*" && m_strExt != "")
                findNextFile();
        }
        
        m_bExtractName = false;
        
		return (m_pDirent != NULL);
	}