Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / C++

A Namespace Extension Toolkit

Rate me:
Please Sign up or sign in to vote.
4.78/5 (10 votes)
21 Mar 2006CPOL12 min read 84.5K   1.7K   42  
This article shows you how to build your own Windows Explorer interfaces to custom data.
/*
 Copyright 2005 Chad Yoshikawa
 http://www.ececs.uc.edu/~yoshikco
 yoshikco@ececs.uc.edu

 This, and other source files, were derived from two GPL'd sources:
 "An Almost Complete Namespace Extension Sample"
 http://www.codeproject.com/shell/NamespaceExtImpl.asp
 Copyright 2005 Pascal Hurni

 AdfView
 http://www.viksoe.dk/code/adfview.htm
 Written by Bjarke Viksoe
 Copyright (c) 2001-2002 Bjarke Viksoe.

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
#pragma once

#include "stdafx.h"
#include "GenericFileSystem.h"
#include "GalaxyShellFolder.h"

class CGalaxyFile;



class CGalaxyShellFolder;

/// An instance of a Generic File System.  This filesystem simply mirrors the contents of a local folder.
/// This filesystem is not used anymore -- see CGalaxyNetworkFileSystem instead.
class CGalaxyFileSystem : 
	public CGenericFileSystem
{

public:
	
	/// Create a new filesystem.
	/// @param folder the folder associated with this filesystem
	/// @param absolute_path the path to mirror.
	CGalaxyFileSystem(CGalaxyShellFolder *folder, std::wstring absolute_path);
	
	// Destructor
	virtual ~CGalaxyFileSystem(); 

	/// Get the path of Galaxy that this filesystem is at. 
	/// @return the root into galaxy that we are installed at.
	std::wstring GetGalaxyPath() {
		return myAbsolutePath;
	}


	// Path helper methods
	std::wstring _ConvertLogicalPathToRealPath(std::wstring path);


	//////////////////////////////////////////////////////////
	// FILESYSTEM OPERATIONS
	//////////////////////////////////////////////////////////

	// Do a 'mkdir'
	HRESULT CreateDirectory(std::wstring path);
	// RMDIR
	/*HRESULT RemoveDirectory(std::wstring path);*/
	// rm
	HRESULT Delete(std::wstring filename);

	// Do a 'stat'
	void ListFile(CGalaxyFilePidl &file, std::wstring path);

	// Do a 'ls'
	void ListFiles(std::vector<CGalaxyFilePidl> &files);
	// Do a 'ls path'
	void ListFiles(std::vector<CGalaxyFilePidl> &files, const std::wstring path);

	void CGalaxyFileSystem::SendCommand(std::wstring command);
	// Create a new file

	// TODO: Finish the GalaxyFile implementation

	HRESULT CreateFile(std::wstring filename, CGalaxyFile &file);
	// Create a new file with FILE_FLAG_NO_BUFFERING set
	
	// this local C++ filesystem doesn't suppor the fast copy yet...
	HRESULT CopyFile(std::wstring src, std::wstring dst) {
		return E_NOTIMPL;
	}

	// Open file for reading
	HRESULT OpenFile(const std::wstring filename, CGalaxyFile &file);
	// Open a directory for reading

	// Get file attributes
	HRESULT GetFileInformation(const std::wstring filename, WIN32_FILE_ATTRIBUTE_DATA& attr_data);


	// Read bytes from a file
	HRESULT Read(std::wstring filename, byte *buffer, ULARGE_INTEGER offset, DWORD num_to_read, DWORD &actually_read);

	// Write bytes to a file
	HRESULT Write(std::wstring filename, byte *buffer, ULARGE_INTEGER offset, DWORD num_to_write, DWORD &actually_written);

protected:
	CGalaxyShellFolder *myFolder;
	std::wstring myAbsolutePath; // absolute path into the galaxy system
	CRITICAL_SECTION m_CriticalSection; 
	
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions