00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: winstl/filesystem/current_directory.hpp 00003 * 00004 * Purpose: Simple class that gets, and makes accessible, the current 00005 * directory. 00006 * 00007 * Created: 10th December 2002 00008 * Updated: 10th August 2009 00009 * 00010 * Home: http://stlsoft.org/ 00011 * 00012 * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software 00013 * All rights reserved. 00014 * 00015 * Redistribution and use in source and binary forms, with or without 00016 * modification, are permitted provided that the following conditions are met: 00017 * 00018 * - Redistributions of source code must retain the above copyright notice, this 00019 * list of conditions and the following disclaimer. 00020 * - Redistributions in binary form must reproduce the above copyright notice, 00021 * this list of conditions and the following disclaimer in the documentation 00022 * and/or other materials provided with the distribution. 00023 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of 00024 * any contributors may be used to endorse or promote products derived from 00025 * this software without specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 * 00039 * ////////////////////////////////////////////////////////////////////// */ 00040 00041 00048 #ifndef WINSTL_INCL_WINSTL_FILESYSTEM_HPP_CURRENT_DIRECTORY 00049 #define WINSTL_INCL_WINSTL_FILESYSTEM_HPP_CURRENT_DIRECTORY 00050 00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00052 # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_CURRENT_DIRECTORY_MAJOR 4 00053 # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_CURRENT_DIRECTORY_MINOR 1 00054 # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_CURRENT_DIRECTORY_REVISION 1 00055 # define WINSTL_VER_WINSTL_FILESYSTEM_HPP_CURRENT_DIRECTORY_EDIT 67 00056 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00057 00058 /* ///////////////////////////////////////////////////////////////////////// 00059 * Compatibility 00060 */ 00061 00062 /* 00063 [Incompatibilies-start] 00064 STLSOFT_COMPILER_IS_MSVC: _MSC_VER<1200 00065 [Incompatibilies-end] 00066 */ 00067 00068 /* ///////////////////////////////////////////////////////////////////////// 00069 * Includes 00070 */ 00071 00072 #ifndef WINSTL_INCL_WINSTL_H_WINSTL 00073 # include <winstl/winstl.h> 00074 #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */ 00075 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SPECIAL_STRING_INSTANCE 00076 # include <stlsoft/string/special_string_instance.hpp> 00077 #endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_SPECIAL_STRING_INSTANCE */ 00078 #ifndef WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS 00079 # include <winstl/filesystem/filesystem_traits.hpp> 00080 #endif /* !WINSTL_INCL_WINSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS */ 00081 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR 00082 # include <winstl/memory/processheap_allocator.hpp> 00083 #endif /* !WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR */ 00084 00085 #if defined(STLSOFT_COMPILER_IS_BORLAND) 00086 // Borland is a bit of a thicky, and requires a (valid) spin_mutex_type 00087 # include <winstl/synch/spin_mutex.hpp> 00088 #endif /* compiler */ 00089 00090 /* ///////////////////////////////////////////////////////////////////////// 00091 * Namespace 00092 */ 00093 00094 #ifndef _WINSTL_NO_NAMESPACE 00095 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00096 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00097 /* There is no stlsoft namespace, so must define ::winstl */ 00098 namespace winstl 00099 { 00100 # else 00101 /* Define stlsoft::winstl_project */ 00102 00103 namespace stlsoft 00104 { 00105 00106 namespace winstl_project 00107 { 00108 00109 # endif /* _STLSOFT_NO_NAMESPACE */ 00110 #endif /* !_WINSTL_NO_NAMESPACE */ 00111 00112 /* ///////////////////////////////////////////////////////////////////////// 00113 * Classes 00114 */ 00115 00121 template <ss_typename_param_k C> 00122 struct cwd_policy 00123 { 00124 typedef C char_type; 00125 typedef processheap_allocator<C> allocator_type; 00126 typedef ss_size_t size_type; 00127 typedef size_type (*pfn_type)(char_type *, size_type); 00128 #if defined(STLSOFT_COMPILER_IS_BORLAND) 00129 // Borland is a bit of a thicky, and requires a (valid) spin_mutex_type 00130 typedef winstl::spin_mutex spin_mutex_type; 00131 #endif /* compiler */ 00132 00133 enum { internalBufferSize = 128 }; 00134 00135 enum { allowImplicitConversion = 1 }; 00136 00137 enum { sharedState = 0 }; 00138 00139 static pfn_type get_fn() 00140 { 00141 return winstl::filesystem_traits<char_type>::get_current_directory; 00142 } 00143 }; 00144 00145 /* ///////////////////////////////////////////////////////////////////////// 00146 * Typedefs for commonly encountered types 00147 */ 00148 00154 typedef stlsoft_ns_qual(special_string_instance_0)< cwd_policy<ws_char_a_t> > current_directory_a; 00160 typedef stlsoft_ns_qual(special_string_instance_0)< cwd_policy<ws_char_w_t> > current_directory_w; 00166 typedef stlsoft_ns_qual(special_string_instance_0)< cwd_policy<TCHAR> > current_directory; 00167 00168 /* ///////////////////////////////////////////////////////////////////////// 00169 * Unit-testing 00170 */ 00171 00172 #ifdef STLSOFT_UNITTEST 00173 # include "./unittest/current_directory_unittest_.h" 00174 #endif /* STLSOFT_UNITTEST */ 00175 00176 /* ////////////////////////////////////////////////////////////////////// */ 00177 00178 #ifndef _WINSTL_NO_NAMESPACE 00179 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00180 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00181 } // namespace winstl 00182 # else 00183 } // namespace winstl_project 00184 } // namespace stlsoft 00185 # endif /* _STLSOFT_NO_NAMESPACE */ 00186 #endif /* !_WINSTL_NO_NAMESPACE */ 00187 00188 /* ////////////////////////////////////////////////////////////////////// */ 00189 00190 #endif /* WINSTL_INCL_WINSTL_FILESYSTEM_HPP_CURRENT_DIRECTORY */ 00191 00192 /* ///////////////////////////// end of file //////////////////////////// */