Exemple #1
0
bool vfsLocalDir::Open(const std::string& path)
{
	if(!vfsDirBase::Open(path))
		return false;

	wxDir dir;

	if(!dir.Open(path))
		return false;

	wxString name;
	for(bool is_ok = dir.GetFirst(&name); is_ok; is_ok = dir.GetNext(&name))
	{
		wxString dir_path = fmt::FromUTF8(path) + name;

		m_entries.emplace_back();
		DirEntryInfo& info = m_entries.back();
		info.name = fmt::ToUTF8(name);

		info.flags |= dir.Exists(dir_path) ? DirEntry_TypeDir : DirEntry_TypeFile;
		if(wxIsWritable(dir_path)) info.flags |= DirEntry_PermWritable;
		if(wxIsReadable(dir_path)) info.flags |= DirEntry_PermReadable;
		if(wxIsExecutable(dir_path)) info.flags |= DirEntry_PermExecutable;
	}

	return true;
}
Exemple #2
0
void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
{
    if( !wxIsWritable( GetProjectFileName() ) )
        return;

    Prj().ConfigSave( PgmTop().SysSearch(), GeneralGroupName, s_KicadManagerParams );
}
void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
{
    if( !wxIsWritable( GetProjectFileName() ) )
        return;

    // was: wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(),
    //          GeneralGroupName, s_KicadManagerParams );
    Prj().ConfigSave( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams );
}
Exemple #4
0
bool CPath::IsFile(EAccess mode) const
{
	if (!wxFileName::FileExists(m_filesystem)) {
		return false;
	} else if ((mode & writable) && !wxIsWritable(m_filesystem)) {
		return false;
	} else if ((mode & readable) && !wxIsReadable(m_filesystem)) {
		return false;
	}

	return true;
}
Exemple #5
0
bool CPath::IsDir(EAccess mode) const
{
	wxString path = DoCleanPath(m_filesystem);
	if (!wxFileName::DirExists(path)) {
		return false;
	} else if ((mode & writable) && !wxIsWritable(path)) {
		return false;
	} else if ((mode & readable) && !wxIsReadable(path)) {
		return false;
	}

	return true;
}
wxString wxvbamApp::GetConfigurationPath()
{
        // first check if config files exists in reverse order
        // (from system paths to more local paths.)
	if (data_path.empty())
	{
		get_config_path(config_path);

		for (int i = config_path.size() - 1; i >= 0 ; i--)
		{
			wxFileName fn(config_path[i], wxT("vbam.ini"));

			if (fn.FileExists() && fn.IsFileWritable())
			{
				data_path = config_path[i];
				break;
			}
		}
	}

        // if no config file was not found, search for writable config
        // dir or parent to create it in in OnInit in normal order
        // (from user paths to system paths.)
        if (data_path.empty())
        {
		for (int i = 0; i < config_path.size() ; i++)
                {
                    // Check if path is writeable
                    if (wxIsWritable(config_path[i]))
                    {
                            data_path = config_path[i];
                            break;
                    }

                    // check if parent of path is writable, so we can
                    // create the path in OnInit
                    wxFileName parent_dir = wxFileName::DirName(config_path[i] + wxT("//.."));
                    parent_dir.MakeAbsolute();

                    if (parent_dir.IsDirWritable())
                    {
                        data_path = config_path[i];
                        break;
                    }
                }
        }

	return data_path;
}
Exemple #7
0
// Sets the NTFS compression flag for a directory or file. This function does not operate
// recursively.  Set compressStatus to false to decompress compressed files (and do nothing
// to already decompressed files).
//
// Exceptions thrown: None.
//   (Errors are logged to console.  Failures are considered non-critical)
//
void NTFS_CompressFile( const wxString& file, bool compressStatus )
{
	bool isFile = !wxDirExists( file );

	if( isFile && !wxFileExists( file ) ) return;
	if( GetFileAttributes(file) & FILE_ATTRIBUTE_COMPRESSED ) return;
	if( !wxIsWritable( file ) ) return;

	const DWORD flags = isFile ? FILE_ATTRIBUTE_NORMAL : (FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_DIRECTORY);

	HANDLE bloated_crap = CreateFile( file,
		FILE_GENERIC_WRITE | FILE_GENERIC_READ,
		FILE_SHARE_READ | FILE_SHARE_DELETE,
		NULL,
		OPEN_EXISTING,
		flags,
		NULL
	);

	// Fail silently -- non-compression of files and folders is not an errorable offense.

	if( !StreamException_LogLastError( file, L"NTFS 压缩提示", bloated_crap ) )
	{
		DWORD bytesReturned = 0;
		DWORD compressMode = compressStatus ? COMPRESSION_FORMAT_DEFAULT : COMPRESSION_FORMAT_NONE;

		/*BOOL result = */DeviceIoControl(
			bloated_crap, FSCTL_SET_COMPRESSION,
			&compressMode, 2, NULL, 0,
			&bytesReturned, NULL
		);

		// No need to see this every time on my exFAT drive (rama)
		//if( !result )
		//	StreamException_LogLastError( file, L"NTFS 压缩提示" );

		CloseHandle( bloated_crap );
	}
}
wxString MainFrame::GetGamePath(wxString path)
{
	wxString game_path = path;

	if (game_path.size())
	{
		game_path = wxGetApp().GetAbsolutePath(game_path);
	}
	else
	{
		game_path = panel->game_dir();
		wxFileName::Mkdir(game_path, 0777, wxPATH_MKDIR_FULL);
	}

	if (!wxFileName::DirExists(game_path))
		game_path = wxFileName::GetCwd();

	if (!wxIsWritable(game_path))
		game_path = wxGetApp().GetConfigurationPath();

	return game_path;
}