summaryrefslogtreecommitdiff
path: root/src/AbstractDiskWriter.cc
Commit message (Collapse)AuthorAgeFilesLines
* mingw32: Make NTFS sparse file on --file-allocation=truncTatsuhiro Tsujikawa2013-01-111-1/+13
|
* mingw32: Use HANDLE only for MinGW32 buildTatsuhiro Tsujikawa2012-12-151-67/+95
|
* Removed warning when --file-allocation=falloc is used in MinGW32 buildTatsuhiro Tsujikawa2012-12-061-5/+0
| | | | | The warning was just a mistake. SetFilePointerEx + SetEndOfFile actually allocate disk space.
* mingw32: Removed FSCTL_SET_SPARSE setTatsuhiro Tsujikawa2012-12-031-8/+0
|
* mingw32: Open file using _wsopen and added --enable-mmap supportTatsuhiro Tsujikawa2012-12-011-137/+180
| | | | | | | | | | | | | | | | | I tried CreateFile but the subsequent ReadFile fails with Access Denied if sparse file is read on NTFS. I mostly reverted previous changes and use _wsopen with read/write share enabled instead of CreateFile. This change also includes --enable-mmap support for MinGW32 build. Memory mapped file may be useful for 64-bits OS and lots of RAM. Currently, FlushViewOfFile is not called during the download, so it is slightly vulnerable against sudden power loss. I found lots of read when resuming download due to page fault. So for now it is useful for the initial download. I recommend not to use --file-allocation=prealloc with --enable-mmap for MinGW32, because it triggers page faults even in the initial download. Anyway, the option is experimental.
* Use Win32 API for file I/O in AbstractDiskWriterTatsuhiro Tsujikawa2012-11-301-41/+135
| | | | Now file has been opened by aria2 is now readable by other processes.
* Set F_GLOBAL_NOCACHE for Mac OS XTatsuhiro Tsujikawa2012-11-281-0/+3
|
* Refactored file open codeTatsuhiro Tsujikawa2012-11-281-25/+21
|
* Removed trailing spacesTatsuhiro Tsujikawa2012-10-011-1/+1
|
* Use int64_t instead of off_tTatsuhiro Tsujikawa2012-07-231-14/+14
| | | | | | | | Using off_t, at least, in DiskAdaptor layer is problematic because torrent can contain under 2GiB files but total sum of those files may exceed 2GiB limit, which makes off_t overflow in 32 bit system without large file support. So we use int64_t in API. We'll check the file length before download so that it does not exceed max off_t.
* Use PRId64 for int64_t format specifierTatsuhiro Tsujikawa2012-06-251-2/+2
|
* Added --enable-mmap option.Tatsuhiro Tsujikawa2012-06-241-18/+97
| | | | | If this option is used, map files into memory using mmap(2). This option is experimental.
* No retry for close() with EINTR. Also reverted changes in d5ffa253.Tatsuhiro Tsujikawa2011-12-251-15/+3
|
* Log filename in the exception when AbstractDiskWriter::closeFile() failed.Tatsuhiro Tsujikawa2011-12-101-2/+4
|
* AbstractDiskWriter::closeFile(): Throw exception if close() failed.Tatsuhiro Tsujikawa2011-12-091-2/+12
| | | | | | | | | | | ~AbstractDiskWriter calles closeFile(), but suppresses exception. MultiDiskAdaptor::closeFile() logs error if child DiskWriter::closeFile() throws exception. This exception is not rethrown. If at least one exception is caught, MultiDiskAdaptor::closeFile() throws new DlAbortEx. RequestGroupMan::closeFile() just logs exception and suppress each exception. Generally, don't call closeFile() in destructor. If you need to call it, it must suppress the exception.
* Replaced uint64_t with off_t or int64_t.Tatsuhiro Tsujikawa2011-12-091-5/+5
| | | | | Since off_t is int64_t with LFS, we cannot take advantage of extra capacity of uint64_t.
* Added global::cerr. windows.h now included from common.hTatsuhiro Tsujikawa2011-08-101-4/+0
| | | | | | | We replaced most of std::cerr with global::cerr. windows.h is now included from common.h. Before including it, we define WINVER. We renamed some variable name because some macros in windows.h collide with them.
* Removed utf8ToNative from log message and exception message.Tatsuhiro Tsujikawa2011-08-081-6/+6
|
* In MinGW32, open file with UNICODE filename and print them in ANSI.Tatsuhiro Tsujikawa2011-08-041-10/+11
|
* Removed use of O_DIRECT because it performs bad.Tatsuhiro Tsujikawa2011-07-161-22/+1
|
* Implemented fast file allocation in MinGW32 build.Tatsuhiro Tsujikawa2011-06-071-1/+18
| | | | | | We use SetFilePointerEx and SetEndOfFile to allocate extents. This only works with NTFS. To enable this feature, --file-allocation=falloc must be given.
* Use %lx for DWORD.Tatsuhiro Tsujikawa2010-12-191-1/+1
| | | | GetLastError() returns DWORD, not C-String.
* Fixed compile error which occurs when system has posix_fallocate() butTatsuhiro Tsujikawa2010-12-051-1/+1
| | | | does not have fallocate().
* Added more error code values.Tatsuhiro Tsujikawa2010-12-011-27/+45
| | | | | I have not set error code for all exception invocation. In this change, I set error code where error likely occurs.
* Renamed Exception::errno_ as Exception::errNum_.Tatsuhiro Tsujikawa2010-11-281-1/+1
|
* Added additional error_code::Values(9 through 14).Tatsuhiro Tsujikawa2010-11-281-2/+3
|
* 2010-11-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-201-30/+27
| | | | | | Replaced StringFormat with fmt
* 2010-11-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-201-8/+6
| | | | | | | Rewritten Logger interface. Logger now writes source file name and line number in log file.
* 2010-11-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-091-4/+9
| | | | | | | | Retry open(2) and fallocate(2) when they are interrupted by signal. * src/AbstractDiskWriter.cc
* 2010-11-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-091-15/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | Capture errno right after system/library call to avoid it to get overwritten. Use util::safeStrerror instead of strerror directly because strerror might return NULL. We don't check errno for std::fstream anymore. * src/AbstractDiskWriter.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTRoutingTableDeserializer.cc * src/DHTRoutingTableSerializer.cc * src/DefaultBtProgressInfoFile.cc * src/EpollEventPoll.cc * src/IteratableChunkChecksumValidator.cc * src/KqueueEventPoll.cc * src/Logger.cc * src/MessageDigestHelper.cc * src/PortEventPoll.cc * src/SelectEventPoll.cc * src/SocketCore.cc * src/message.h * src/util.cc * src/util.h
* 2010-10-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-10-111-12/+14
| | | | | | | Rewritten AbstractDiskWriter::openFile() without File::exists(). * src/AbstractCommand.cc
* 2010-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-07-041-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | When allocating disk space, for Linux system with fallocate() system call, first check file system supports fallocate. This just run fallocate with small chunk and see it succeeds or fails. If it succeeds, use fallocate() to allocate entire file otherwise fall back to traditional slower method: writing zeros. This behavior is enabled in --file-allocation=prealloc, so this is enabled by default for most modern Linux. * configure.ac * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/AbstractSingleDiskAdaptor.cc * src/AdaptiveFileAllocationIterator.cc * src/AdaptiveFileAllocationIterator.h * src/DefaultPieceStorage.cc * src/DiskAdaptor.cc * src/DiskAdaptor.h * src/FallocFileAllocationIterator.cc * src/Makefile.am * src/MultiFileAllocationIterator.cc * src/OptionHandlerFactory.cc * test/FallocFileAllocationIteratorTest.cc * test/Makefile.am
* 2010-06-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-06-211-38/+38
| | | | | | | Changed naming standards for class member variable: now it looks like var_ instead of _var.
* 2010-06-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-06-111-19/+19
| | | | | | | | Made protected member variable private. Added accessor funcs. * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h
* 2010-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-01-241-1/+1
| | | | | | | | | | | | | | | Fixed compile error with i586-mingw32msvc-g++. Always Cut console readout by 80 characters in mingw32 build. Catch exception in DHTMessageReceiver::receiveMessage(). * src/AbstractDiskWriter.cc * src/ConsoleStatCalc.cc * src/DHTMessageReceiver.cc * src/File.cc * src/RequestGroupMan.cc * src/a2io.h * test/FileTest.cc
* 2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-01-051-9/+9
| | | | | | | | | Untabify. Fixed one line in copyright which is longer than 80 columns. * src * test
* 2009-10-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2009-10-221-1/+1
| | | | | | | | | | Renamed Util.{cc,h} as util.{cc,h} * src/Util.cc * src/Util.h * src/util.cc * src/util.h
* 2009-10-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2009-10-221-1/+1
| | | | | | | | Moved static functions in Util class to namespace util. * src * test
* 2009-05-18 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2009-05-181-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added source filename(__FILE__) and line number(__LINE__) to exception message. * src/AbstractCommand.cc * src/AbstractDiskWriter.cc * src/AbstractProxyResponseCommand.cc * src/BDE.h * src/BtAllowedFastMessage.cc * src/BtHandshakeMessageValidator.h * src/BtHaveAllMessage.cc * src/BtHaveNoneMessage.cc * src/BtPieceMessage.cc * src/BtRejectMessage.cc * src/ChunkedDecoder.cc * src/CookieStorage.cc * src/DHTAnnouncePeerMessage.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTMessageFactoryImpl.cc * src/DHTMessageTracker.cc * src/DHTRoutingTableDeserializer.cc * src/DHTRoutingTableSerializer.cc * src/DHTSetup.cc * src/DHTTokenTracker.cc * src/DefaultBtAnnounce.cc * src/DefaultBtContext.cc * src/DefaultBtInteractive.cc * src/DefaultBtMessageFactory.cc * src/DefaultBtProgressInfoFile.cc * src/DefaultExtensionMessageFactory.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadEngineFactory.cc * src/DownloadFailureException.h * src/Exception.cc * src/Exception.h * src/ExpatMetalinkProcessor.cc * src/ExpatXmlRpcRequestProcessor.cc * src/FallocFileAllocationIterator.cc * src/FatalException.h * src/FtpConnection.cc * src/FtpFinishDownloadCommand.cc * src/FtpInitiateConnectionCommand.cc * src/FtpNegotiationCommand.cc * src/GZipDecoder.cc * src/HandshakeExtensionMessage.cc * src/HttpConnection.cc * src/HttpHeaderProcessor.cc * src/HttpInitiateConnectionCommand.cc * src/HttpResponse.cc * src/HttpResponseCommand.cc * src/HttpServer.cc * src/HttpSkipResponseCommand.cc * src/InitiateConnectionCommandFactory.cc * src/IteratableChunkChecksumValidator.cc * src/LibgcryptARC4Context.h * src/LibgcryptARC4Decryptor.h * src/LibgcryptARC4Encryptor.h * src/LibgcryptDHKeyExchange.h * src/LibgnutlsTLSContext.cc * src/LibsslARC4Context.h * src/LibsslARC4Decryptor.h * src/LibsslARC4Encryptor.h * src/LibsslDHKeyExchange.h * src/LibsslTLSContext.cc * src/MSEHandshake.cc * src/MessageDigestHelper.cc * src/MetalinkHelper.cc * src/MultiDiskAdaptor.cc * src/NameMatchOptionHandler.h * src/NameResolver.cc * src/Netrc.cc * src/NsCookieParser.cc * src/OptionHandlerException.cc * src/OptionHandlerException.h * src/OptionHandlerImpl.h * src/OptionParser.cc * src/ParameterizedStringParser.cc * src/PeerAbstractCommand.cc * src/PeerConnection.cc * src/PeerMessageUtil.cc * src/PeerReceiveHandshakeCommand.cc * src/Platform.cc * src/ReceiverMSEHandshakeCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/SimpleLogger.cc * src/SocketCore.cc * src/Sqlite3MozCookieParser.cc * src/UTPexExtensionMessage.cc * src/Util.cc * src/XML2SAXMetalinkProcessor.cc * src/Xml2XmlRpcRequestProcessor.cc * src/XmlRpcMethodImpl.cc * src/bencode.cc * src/download_helper.cc * src/messageDigest.h * test/ExceptionTest.cc * test/TestUtil.cc
* 2009-05-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2009-05-041-0/+1
| | | | | | | | | | | | | | | | | | | Removed directIOAllowed() from BinaryStream, DiskWriter, DiskAdaptor. setDirectIOAllowed() was renamed as allowDirectIO(). Removed _directIOAllowed member from DiskWriter. * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/AbstractSingleDiskAdaptor.cc * src/AbstractSingleDiskAdaptor.h * src/BinaryStream.h * src/ByteArrayDiskWriter.h * src/DefaultPieceStorage.cc * src/DiskWriter.h * src/MultiDiskAdaptor.cc * src/MultiDiskAdaptor.h
* 2009-05-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2009-05-041-33/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now the constructor of AbstractDiskWriter takes filename as an argument and filename argument is removed from openFile(), initAndOpenFile(), openExistingFile() interface. storeDir member and its accessor functions are removed from DiskAdaptor because it is not used anymore. size() member function of DefaultDiskWriter, DirectDiskAdaptor and MultiDiskAdaptor now can be called without opening file. * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/AbstractSingleDiskAdaptor.cc * src/AbstractSingleDiskAdaptor.h * src/ByteArrayDiskWriter.cc * src/ByteArrayDiskWriter.h * src/ByteArrayDiskWriterFactory.cc * src/ByteArrayDiskWriterFactory.h * src/DefaultDiskWriter.cc * src/DefaultDiskWriter.h * src/DefaultDiskWriterFactory.cc * src/DefaultDiskWriterFactory.h * src/DefaultPieceStorage.cc * src/DirectDiskAdaptor.cc * src/DirectDiskAdaptor.h * src/DiskAdaptor.h * src/DiskWriter.h * src/DiskWriterFactory.h * src/MessageDigestHelper.cc * src/MultiDiskAdaptor.cc * src/RequestGroup.cc * src/UnknownLengthPieceStorage.cc * src/Util.cc * test/DefaultDiskWriterTest.cc * test/DirectDiskAdaptorTest.cc * test/FallocFileAllocationIteratorTest.cc * test/MessageDigestHelperTest.cc * test/MetalinkProcessorTest.cc * test/MultiDiskAdaptorTest.cc * test/MultiFileAllocationIteratorTest.cc * test/SingleFileAllocationIteratorTest.cc * test/UtilTest.cc
* 2009-03-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2009-03-251-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added 'falloc' parameter for --file-allocation option. 'falloc' allocation mode uses posix_fallocate() system call to allocate file on disk. If you are using newer file systems such as ext4 (with extents support), btrfs or xfs, 'falloc' is your best choice. It allocates large(few GiB) files almost instantly. Don't use 'falloc' with legacy file systems such as ext3 because it takes almost same time as 'prealloc' and it blocks aria2 entirely until allocation finishes. 'falloc' may not be available if your system doesn't have posix_fallocate() system call. * configure.ac * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/AbstractSingleDiskAdaptor.cc * src/BinaryStream.h * src/BtCheckIntegrityEntry.cc * src/ByteArrayDiskWriter.h * src/CheckIntegrityEntry.cc * src/CheckIntegrityEntry.h * src/DefaultPieceStorage.cc * src/DiskAdaptor.cc * src/DiskAdaptor.h * src/DiskWriter.h * src/FallocFileAllocationIterator.cc * src/FallocFileAllocationIterator.h * src/FileAllocationEntry.cc * src/FileAllocationEntry.h * src/Makefile.am * src/MultiFileAllocationIterator.cc * src/MultiFileAllocationIterator.h * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/StreamCheckIntegrityEntry.cc * src/prefs.cc * src/prefs.h * src/usage_text.h * test/FallocFileAllocationIteratorTest.cc * test/Makefile.am
* 2009-02-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2009-02-231-1/+19
| | | | | | | | | | | | | | | | | | In BitTorrent, Open files in read-only mode for hash check. After that, re-open file in read/write mode only when the download is not finished. * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/AbstractSingleDiskAdaptor.cc * src/AbstractSingleDiskAdaptor.h * src/BtCheckIntegrityEntry.cc * src/DiskAdaptor.h * src/DiskWriter.h * src/MultiDiskAdaptor.cc * src/MultiDiskAdaptor.h * src/RequestGroup.cc
* 2008-11-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2008-11-171-1/+1
| | | | | | | | | | | | | Rewritten ByteArrayDiskWriter::size() using seekg() and tellg(). Removed const qualifier from DiskWriter::size(). * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/ByteArrayDiskWriter.cc * src/ByteArrayDiskWriter.h * src/DiskWriter.h * test/ByteArrayDiskWriterTest.cc
* 2008-10-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-10-011-4/+26
| | | | | | | | | | Use seek() and SetEndOfFile() for mingw32 build instead of ftruncate(), because mingw32's ftruncate() cannot handle more than 2GB-size file. * src/AbstractDiskWriter.cc
* 2008-08-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-08-231-1/+1
| | | | | | | Fixed error handling of lseek. * src/AbstractDiskWriter.cc
* 2008-07-13 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-07-131-1/+1
| | | | | | | | | | Use File::exists() instead of File::isFile() to allow non-regular file such as block spacial device. * src/AbstractDiskWriter.cc * src/MultiDiskWriter.cc
* 2008-07-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-07-061-1/+1
| | | | | | | | | | | | | | | Introduced a2_struct_stat. It is defined as `struct _stati64' if __MINGW32__ is defined, because under MinGW32, _stati64 is used and its second argument is of type `struct _stati64'. Otherwise it is defined as `struct stat'. * src/AbstractDiskWriter.cc * src/File.cc * src/File.h * src/a2io.h
* 2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-06-161-0/+7
| | | | | | | | | | | | | | | | | | | | When there is not enough space in disk when writing a chunk of data, aria2 now prints the message to the console to warn user and aborts its download. Not all downloads are canceled because some downloads may use another disk or partition. BUG#1640332 * src/AbstractDiskWriter.cc * src/PeerAbstractCommand.cc * src/PeerAbstractCommand.h: Added onFailure() function for override. * src/PeerInteractionCommand.cc: In onFailure(), call RequestGroup:: setHaltRequested(true) to cancel download. * src/PeerInteractionCommand.h
* 2008-04-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>Tatsuhiro Tsujikawa2008-04-271-8/+12
| | | | | | | | | | | | | Rewritten Exception class. Throw exception object, not its pointer and catch by reference, so that remove problematic delete operator for catched exception. * src/Exception.cc * src/Exception.h * test/ExceptionTest.cc * src/*: All files throwing/catching exception. * test/*: All files throwing/catching exception.