summaryrefslogtreecommitdiff
path: root/src/AbstractDiskWriter.cc
Commit message (Collapse)AuthorAgeFilesLines
* Don't inherit file descriptor to child processTatsuhiro Tsujikawa2016-02-081-0/+1
| | | | | | For non-Mingw32 build, set FD_CLOEXEC to file descriptors which live beyond function scope. For Mingw32 build, just pass false to bInheritHandles parameter of CreateProcessW.
* mingw: Use SetFileValidData to make --file-allocation=falloc workTatsuhiro Tsujikawa2016-01-281-0/+9
|
* mingw: Add formatLastError as wrapper function for FormatMessageTatsuhiro Tsujikawa2016-01-281-7/+5
|
* make clang-format using clang-format-3.6Tatsuhiro Tsujikawa2015-12-271-194/+191
|
* Use cached filesize instead of calling size() againTatsuhiro Tsujikawa2015-11-141-1/+1
|
* Don't enable mmap if file allocation is disabledTatsuhiro Tsujikawa2015-11-121-5/+11
| | | | | | | Without file allocation, we cannot map file because file length could be zero. This could fix bug reported at GH-478
* Disard cache when checking checksumTatsuhiro Tsujikawa2014-07-021-0/+8
| | | | This will slow down checksum checking but does not thrash cache.
* OSX: Use F_NOCACHE instead of F_GLOBAL_NOCACHENils Maier2014-05-261-2/+2
| | | | | The latter persists for the lifetime of the file, while the former affects only the current descriptor.
* Fix (unknown length) downloads larger than 2GiBNils Maier2014-05-251-0/+1
| | | | Closes #215
* Fix F_PREALLOC based allocation on some OSX versionsNils Maier2014-05-081-4/+12
|
* Remove unused function getWin32HandleNils Maier2014-05-081-9/+0
|
* Implement falloc equivalent in OSXNils Maier2014-04-121-0/+18
|
* Clean up if defined styleTatsuhiro Tsujikawa2013-09-171-2/+2
|
* Convert most 0/NULL pointers to nullptrNils Maier2013-08-201-4/+4
| | | | Courtesy of llvm cpp11-migrate 3.3
* Support off64_t for Android buildTatsuhiro Tsujikawa2013-05-061-2/+2
| | | | | | | | Android NDK R8e does not provide ftruncate64, but bionic has the assembler code to access kernel function. We borrowed those ftruncate64.S files from android source code repository. It turns out that x86 asm.h in NDK R8e is also broken, so latest asm.h was also borrowed.
* 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