示例#1
0
/*
* Test if the specifi @param path is a file and readable
* @param path the path of the file to test
* @return true or false
*/
int rtw_is_file_readable(char *path)
{
	if (isFileReadable(path) == 0)
		return true;
	else
		return false;
}
/*
* Test if the specifi @param path is a file and readable
* @param path the path of the file to test
* @return _TRUE or _FALSE
*/
int rtw_is_file_readable(char *path)
{
#ifdef PLATFORM_LINUX
	if(isFileReadable(path) == 0)
		return _TRUE;
	else
		return _FALSE;
#else
	//Todo...
	return _FALSE;
#endif
}
bool VirtualKinectCapture::parseFileList(const std::string vkDatas)
{
    std::ifstream fs(vkDatas.c_str());

    if (fs.is_open())
    {           
        do 
        {
            std::string line;
            std::getline(fs, line);

            if (line.empty())
                continue;

            int found = -1;
            found = line.find_first_not_of(" │:");
            if (found>=0)
            {
                line = line.substr(found);
            }

            if (line[line.length()-1] == '\n')
                line = line.substr(0, line.length()-1);

            found = findSubString(line, "depth");
            if (found>=0 && isFileReadable(line))
            {
                found = line.find_last_of('.');
                if (found>=0)
                {
                    std::string fmt = line.substr(found+1, line.length());
                    std::transform(fmt.begin(), fmt.end(), fmt.begin(), ::tolower);

                    VK_DEPTH_FILE_TYPE type = VK_DEPTH_FILE_UNKOWN; 
                    if (fmt.compare("avi") == 0)
                    {
                        type = VK_DEPTH_FILE_VIDEO;
                    }
                    else if (fmt.compare("png") == 0)
                    {
                        type = VK_DEPTH_FILE_IMAGE;
                    }

                    if (type != VK_DEPTH_FILE_UNKOWN)
                    {
                        if (depthFileType_ == VK_DEPTH_FILE_UNKOWN)
                            depthFileType_ = type;

                        // ensure that the format of depth file is unique
                        if (type == depthFileType_) 
                            depthFile_.push_back(line);
                    }
                }
            }

            found = findSubString(line, "color");
            if (found>=0 && isFileReadable(line))
            {
                found = line.find_last_of('.');
                if (found>=0)
                {
                    std::string fmt = line.substr(found+1, line.length());
                    std::transform(fmt.begin(), fmt.end(), fmt.begin(), ::tolower);

                    VK_DEPTH_FILE_TYPE type = VK_COLOR_FILE_UNKOWN;
                    if (fmt.compare("avi") == 0)
                    {
                        type = VK_COLOR_FILE_VIDEO;
                    }
                    else if (fmt.compare("png") == 0)
                    {
                        type = VK_COLOR_FILE_IMAGE;
                    }

                    if (type != VK_COLOR_FILE_UNKOWN)
                    {
                        if (colorFileType_ == VK_COLOR_FILE_UNKOWN)
                            colorFileType_ = type;

                        // ensure that the format of depth file is unique
                        if (type == colorFileType_)
                            colorFile_.push_back(line);
                    }
                }
            }

        } while (!fs.eof());
    }
    else
    {
        showError( cv::format("Failed to open %s", vkDatas.c_str()) );
    }

    if (!depthFile_.empty() && !colorFile_.empty())
    {
        //std::ofstream ofs(vkDatas.c_str(), std::ios::out);
        //if (ofs.is_open())
        //{
        //    for (int i = 0; i < depthFile_.size(); i++)
        //        ofs << depthFile_[i] << std::endl;

        //    for (int j = 0; j < colorFile_.size(); j++)
        //        ofs << colorFile_[j] << std::endl;

        //    ofs.close();
        //}

        return true;
    }
    else
        return false;
}