Example #1
0
IImageProvider * ImagesProvider::create(const QString & source)
{
	if (PathIsDirectoryA(source.toStdString().c_str()) || IsSupported(source))
		return new ImagesProvider(source);
			
	return nullptr;
}
/**
 * Checks if a certain path exists and is a folder.
 * @param path Full path to folder.
 * @return Does it exist?
 */
bool folderExists(const std::string &path)
{
#ifdef _WIN32
	return (PathIsDirectoryA(path.c_str()) != FALSE);
#else
	struct stat info;
	return (stat(path.c_str(), &info) == 0 && S_ISDIR(info.st_mode));
#endif
}
Example #3
0
static BOOL MyIsDirectory(const std::string& path)
{
#ifdef __BORLANDC__
    return (GetFileAttributes(path.c_str()) & FILE_ATTRIBUTE_DIRECTORY);
#else
// See http://msdn.microsoft.com/en-us/library/bb773621(VS.85).aspx
    return PathIsDirectoryA(path.c_str());
#endif
}
Example #4
0
bool is_directory(const std::string& path) {
#ifdef __unix__
    struct stat buffer;
    stat(path.c_str(), &buffer);
    return S_ISDIR(buffer.st_mode);
#elif _WIN32
    return (PathIsDirectoryA(path.c_str()) == (BOOL)FILE_ATTRIBUTE_DIRECTORY);
#endif
}
Example #5
0
static BOOL BuildAndSetFolderPath(
    HKEY hKey,
    DWORD dwFlags,
    DWORD csidl,
    LPSTR szPath)
{
    if (dwFlags & CSIDL_MYFLAG_RELATIVE)
    {
        if (!GetWindowsDirectoryA(szPath, MAX_PATH))
            return FALSE;
        PathAddBackslashA(szPath);
    }
#ifdef __APPLE__
    /* On the Apple, user prefs are stored on P:\ which gets
       mapped into the user's preferences folder */
    else if ((dwFlags & (CSIDL_MYFLAG_USERPREFS | CSIDL_MYFLAG_ALLPREFS)) &&
             PathIsDirectoryA ("P:\\"))
    {
        if (dwFlags & CSIDL_MYFLAG_USERPREFS)
            strcpy (szPath, "P:\\User\\");
        else if (dwFlags & CSIDL_MYFLAG_ALLPREFS)
            strcpy (szPath, "P:\\All Users\\");
    }
#endif
    else
    {
        strcpy(szPath, "C:\\");
        if (dwFlags & CSIDL_MYFLAG_USERPREFS)
            strcat (szPath, "Documents and Settings\\User\\");
        else if (dwFlags & CSIDL_MYFLAG_ALLPREFS)
            strcat (szPath, "Documents and Settings\\All Users\\");
    }
    if (CSIDL_Data[csidl].szDefaultPath[0])
        strcat(szPath, CSIDL_Data[csidl].szDefaultPath);
    else
    {
       size_t Len;

       /* Remove trailing backslash, as paths from this set of shell functions
          shouldn't have them */
       Len = strlen (szPath);
       if (szPath[Len - 1] == '\\')
          szPath[Len - 1] = 0;
    }

    if (hKey && RegSetValueExA(hKey,CSIDL_Data[csidl].szValueName,0,REG_SZ,
                               (LPBYTE)szPath,strlen(szPath)+1))
    {
        return FALSE;
    }

    SHCreateDirectoryExA (NULL, szPath, NULL);
    return TRUE;
}
Example #6
0
//
// ----------------------------------------------------------------------------
//
bool CMemoryIniFile::isPathExisting(void)
{
    std::string strIniFile = m_strIniFile;
    strIniFile.reserve ( 2*MAX_PATH );
    LPSTR   szPath = (LPSTR) strIniFile.c_str();
    if (!std::string( PathFindExtensionA( szPath )).empty())
    {
        PathRemoveFileSpecA( szPath );
    }    
    str::ResizeByZeroTermination( strIniFile );
    BOOL bRC = PathIsDirectoryA( (char*) strIniFile.c_str() ); 

    return (bRC != FALSE);
}
Example #7
0
bool FileUtil::isDirectory(const char *path)
{
#ifdef OS_WINDOWS
    return PathIsDirectoryA(path) ? true : false;
#else
    DIR *pdir = opendir(path);
    if(pdir != NULL)
    {
        closedir(pdir);
        pdir = NULL;
        return true;
    }
    return false;
#endif
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void StartGraphicsTest()
{
	const char* testDirectory = "ScreenShotTest";
#if _WIN32
	if (!PathIsDirectoryA(testDirectory))
	{
		CreateDirectoryA(testDirectory, NULL);
	}
#else
	mkdir( testDirectory,
		S_IRUSR | S_IWUSR | S_IXUSR |
		S_IRGRP | S_IWGRP | S_IXGRP |
		S_IROTH | S_IXOTH | S_IXOTH);
#endif
}
Example #9
0
static void CreateShaderCacheDirectory()
{
	const char* shaderCacheDirectory = "ShaderCache";
#if _WIN32
	if (!PathIsDirectoryA(shaderCacheDirectory))
	{
		CreateDirectoryA(shaderCacheDirectory, NULL);
	}
#else
	mkdir(shaderCacheDirectory,
		S_IRUSR | S_IWUSR | S_IXUSR |
		S_IRGRP | S_IWGRP | S_IXGRP |
		S_IROTH | S_IXOTH | S_IXOTH);
#endif
}
Example #10
0
///
///	@brief	파일 첨부 DLG 제어
///
BOOL WINAPI GetOpenFileNameACallback(
  _Inout_ LPOPENFILENAMEA lpofn
)
{
	_TRACE(L"");
	CString strURL = GetURL();
	BOOL bRet = FALSE;

	/// 파일 첨부 차단
	if(TRUE == pRule->IsBlockAttachFile())
	{
		/// 파일 첨부 허가 URL 검사
		if(TRUE == SearchStringFromFile(ALLOW_ATTACH_FILE_URL_TXT, strURL))
			bRet = GetOpenFileNameANext(lpofn);
		else
		{
			AfxMessageBox(L"Mini-DLP에 의해 파일 첨부가 차단됩니다.");
			return FALSE;
		}
	}
	else
		bRet = GetOpenFileNameANext(lpofn);

	/// 첨부 파일 로그를 남김
	if(TRUE == pRule->IsLoggingMail() && TRUE == pRule->IsLoggingAttachFile())
	{
		if(NULL != *lpofn->lpstrFile)
		{
			if(FALSE == PathIsDirectoryA(lpofn->lpstrFile))
				MakeLogFile(LOG_WEB_FILE, (CString)lpofn->lpstrFile);
			else
			{
				CStringArray strArr;
				/// 포인터 연산을 위해 저장
				LPCSTR lpTemp = lpofn->lpstrFile;
				while(TRUE)
				{
					lpTemp += strlen(lpTemp) + 1;
					if(NULL != *lpTemp)
						MakeLogFile(LOG_WEB_FILE,(CString)lpofn->lpstrFile + L"\\" + (CString)lpTemp);
					else
						break;
				}
			}
		}
	}
	return bRet;
};
Example #11
0
/**
 * Checks if a certain path exists and is a folder.
 * @param path Full path to folder.
 * @return Does it exist?
 */
bool folderExists(const std::string &path)
{
#ifdef _WIN32
	return (PathIsDirectoryA(path.c_str()) != FALSE);
#elif __MORPHOS__
	BPTR l = Lock( path.c_str(), SHARED_LOCK );
	if( l != NULL )
	{
		UnLock( l );
		return 1;
	}
	return 0;
#else
	struct stat info;
	return (stat(path.c_str(), &info) == 0 && S_ISDIR(info.st_mode));
#endif
}
Example #12
0
bool IsDirectory(std::string path)
{
#ifdef WIN32
	return PathIsDirectoryA(path.c_str()) ? true : false;
#else
	DIR * pdir = opendir(path.c_str());
	if (pdir == NULL)
	{
		return false;
	}
	else
	{
		closedir(pdir);
		pdir = NULL;
		return true;
	}
#endif
}
		CommandExecutionResults CatCommand::Execute(const ExecutionContext& context)
		{
			auto& currentDir = GetCurrentPath(this->context->UserData, context.Message->SourceProtocol, context.Message->Sender);
			std::string path = SanitizePath(context.ParseResults->GetParameter("file"));
			std::string newPath = JoinPath(currentDir, path);
			if (newPath.empty())
			{
				throw Exceptions::ExecutionException(InvalidPath);
			}
			if (PathIsDirectoryA(newPath.c_str()))
			{
				throw Exceptions::ExecutionException(PathIsNotFile);
			}
			if (!PathFileExistsA(newPath.c_str()))
			{
				throw Exceptions::ExecutionException(FileDoesNotExist);
			}

			std::ifstream file(newPath, std::ios_base::binary);
			file.seekg(0, std::ios_base::end);
			int64_t length = file.tellg();
			file.seekg(0, std::ios_base::beg);
			if (length == -1 || !file)
			{
				throw Exceptions::ExecutionException(CannotReadFile);
			}
			if (length > MaxFileLength)
			{
				length = MaxFileLength;
			}

			std::unique_ptr<char[]> buffer(new char[(unsigned)length + 1]);
			if (file.read(buffer.get(), length).bad())
			{
				throw Exceptions::ExecutionException(CannotReadFile);
			}
			buffer.get()[length] = 0;
			return CommandExecutionResults(std::string(buffer.get()));
		}
		CommandExecutionResults StoreTextCommand::Execute(const ExecutionContext& context)
		{
			auto& currentDir = GetCurrentPath(this->context->UserData, context.Message->SourceProtocol, context.Message->Sender);
			auto& content = context.ParseResults->GetParameter("content");
			auto path = SanitizePath(context.ParseResults->GetParameter("file"));
			auto newPath = JoinPath(currentDir, path);
			if (newPath.empty())
			{
				throw Exceptions::ExecutionException(InvalidPath);
			}
			if (PathIsDirectoryA(newPath.c_str()))
			{
				throw Exceptions::ExecutionException(PathIsNotFile);
			}

			std::ofstream file(newPath, std::ios_base::binary | std::ios_base::trunc);
			file.write(content.c_str(), content.size());
			if (!file)
			{
				throw Exceptions::ExecutionException(CannotWriteToFile);
			}
			return CommandExecutionResults(FileWritten);
		}
Example #15
0
/**
 * Checks if a certain path exists and is a folder.
 * @param path Full path to folder.
 * @return Does it exist?
 */
bool folderExists(const std::string &path)
{
    return (PathIsDirectoryA(path.c_str()) != FALSE);
}
Example #16
0
/*************************************************************************
 * PathIsDirectory	[SHELL32.159]
 */
BOOL WINAPI PathIsDirectoryAW (LPCVOID lpszPath)
{
	if (SHELL_OsIsUnicode())
	  return PathIsDirectoryW (lpszPath);
	return PathIsDirectoryA (lpszPath);
}