⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 win32file.hpp

📁 "More for C++" is a class library that provides some features that are usually common for object ori
💻 HPP
字号:
////  This file is part of the "More for C++" library////  Copyright (c) 1999-2003 by Thorsten Goertz (thorsten@morefor.org)////  The "More for C++" library is free software; you can redistribute it and/or//  modify it under the terms of the license that comes with this package.////  Read "license.txt" for more details.////  THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED//  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES//  OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.////////////////////////////////////////////////////////////////////////////////#ifndef WIN32FILE_HPP#define WIN32FILE_HPP////////////////////////////////////////////////////////////////////////////////// "windows.h" must have been included!!!#include <more/core/finalizable.hpp>#include <more/os/file.hpp>////////////////////////////////////////////////////////////////////////////////namespace more{  namespace os  {    namespace win32    {      class Win32Directory: public Directory, public more::core::Finalizable      {        public:          class Win32Entry: public Directory::Entry          {            public:              Win32Entry( const p<Entry>& pParent, const String& sName );              Win32Entry( const String& sFullName );              virtual String getName( ) throw( more::io::IOException );              virtual String getFullName( ) throw( more::io::IOException );              virtual String getExtension( ) throw( more::io::IOException );              virtual p<Entry> getParent( ) throw( more::io::IOException );              virtual bool isDirectory( ) throw( more::io::IOException );              virtual bool isReadOnly( ) throw( more::io::IOException );              virtual size_t getSize( ) throw( more::io::IOException );            protected:              void throwIfInvalid( ) const;            private:              String    m_sName;              p<Entry>  m_pParent;              String    m_sFullName;          };          Win32Directory( const p<Directory>& pParent, const String& sName );          Win32Directory( const p<Entry>& pDescriptor );          Win32Directory( const String& sFullName );          virtual void finalize( );          virtual bool exists( ) throw( more::io::IOException );          virtual p<Entry> getDescriptor( ) throw( more::io::IOException );          virtual p<Directory> getParent( ) throw( more::io::IOException );          virtual p<Entry> getFirstEntry( ) throw( more::io::IOException );          virtual p<Entry> getNextEntry( ) throw( more::io::IOException );        private:          String    m_sFullName;          p<Entry>  m_pDescriptor;          HANDLE    m_hFindHandle;      };      ////////////////////////////////////////////////////////////////////////      class Win32File: public File, public more::core::Finalizable      {        public:          Win32File( const p<Directory>& pParent, const String& sName );          Win32File( const p<Directory::Entry>& pDescriptor );          Win32File( const String& sFullName );          virtual void finalize( );          virtual bool exists( ) throw( more::io::IOException );          virtual p<Directory::Entry> getDescriptor( );          virtual p<Directory> getParent( ) throw( more::io::IOException );          virtual void open( AccessMode ) throw( more::io::IOException );          virtual void close( ) throw( more::io::IOException );          virtual p<more::io::InputStream> getInputStream( ) throw( more::io::IOException );          virtual p<more::io::OutputStream> getOutputStream( ) throw( more::io::IOException );        protected:          void throwIfNotOpen( HANDLE hFileHandle ) const throw( more::io::IOException );          void throwIfAlreadyOpen( HANDLE hFileHandle ) const throw( more::io::IOException );        private:          String                    m_sFullName;          p<Directory::Entry>       m_pDescriptor;          HANDLE                    m_hWin32ReadHandle;          HANDLE                    m_hWin32WriteHandle;          File::AccessMode          m_eAccessMode;          p<more::io::InputStream>  m_pInputStream;          p<more::io::OutputStream> m_pOutputStream;        // For Win32FileInputStream/Win32FileOutputStream:        public:          virtual size_t available( ) throw( more::io::IOException );          virtual bool hasBeenClosed( ) throw( more::io::IOException );          virtual size_t skip( size_t nNoOfBytes ) throw( more::io::IOException );          virtual size_t read( void* pBuffer, size_t nMaxNoOfBytes ) throw( more::io::IOException );          virtual void write( const void*  pBuffer, size_t nNoOfBytes ) throw( more::io::IOException );          virtual size_t rewind( size_t nNoOfBytes ) throw( more::io::IOException );          virtual void flush( ) throw( more::io::IOException );        // For Win32Directory:        public:          virtual size_t getSize( );      };      ////////////////////////////////////////////////////////////////////////      class Win32FileInputStream: public more::io::InputStream      {        public:          Win32FileInputStream( const p<Win32File>& );          virtual size_t available( ) throw( more::io::IOException );          virtual bool hasBeenClosed( ) throw( more::io::IOException );          virtual size_t skip( size_t nNoOfBytes ) throw( more::io::IOException );          virtual size_t read( void*  pBuffer, size_t  nMaxNoOfBytes ) throw( more::io::IOException );        private:          p<Win32File> m_pWin32File;      };      ////////////////////////////////////////////////////////////////////////      class Win32FileOutputStream: public more::io::OutputStream      {        public:          Win32FileOutputStream( const p<Win32File>& );          virtual void write( const void*  pBuffer, size_t nNoOfBytes ) throw( more::io::IOException );          virtual size_t rewind( size_t nNoOfBytes ) throw( more::io::IOException );          virtual bool hasBeenClosed( ) throw( more::io::IOException );          virtual void flush( ) throw( more::io::IOException );        private:          p<Win32File> m_pWin32File;      };    }  }}////////////////////////////////////////////////////////////////////////////////#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -