mirror of https://github.com/aria2/aria2
				
				
				
			2009-03-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed --direct-file-mapping option and CopyDiskAdaptor. * src/CopyDiskAdaptor.cc: Removed * src/CopyDiskAdaptor.h: Removed * src/DefaultPieceStorage.cc * src/Makefile.am * src/OptionHandlerFactory.cc * src/prefs.cc * src/prefs.h * src/usage_text.h * test/CopyDiskAdaptorTest.cc: Removed * test/Makefile.ampull/1/head
							parent
							
								
									173a86febc
								
							
						
					
					
						commit
						176c9d2002
					
				
							
								
								
									
										14
									
								
								ChangeLog
								
								
								
								
							
							
						
						
									
										14
									
								
								ChangeLog
								
								
								
								
							| 
						 | 
				
			
			@ -1,3 +1,17 @@
 | 
			
		|||
2009-03-10  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 | 
			
		||||
 | 
			
		||||
	Removed --direct-file-mapping option and CopyDiskAdaptor.
 | 
			
		||||
	* src/CopyDiskAdaptor.cc: Removed
 | 
			
		||||
	* src/CopyDiskAdaptor.h: Removed
 | 
			
		||||
	* src/DefaultPieceStorage.cc
 | 
			
		||||
	* src/Makefile.am
 | 
			
		||||
	* src/OptionHandlerFactory.cc
 | 
			
		||||
	* src/prefs.cc
 | 
			
		||||
	* src/prefs.h
 | 
			
		||||
	* src/usage_text.h
 | 
			
		||||
	* test/CopyDiskAdaptorTest.cc: Removed
 | 
			
		||||
	* test/Makefile.am
 | 
			
		||||
 | 
			
		||||
2009-03-10  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 | 
			
		||||
 | 
			
		||||
	Rewritten isSameFileBeingDownloaded()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,88 +0,0 @@
 | 
			
		|||
/* <!-- copyright */
 | 
			
		||||
/*
 | 
			
		||||
 * aria2 - The high speed download utility
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
			
		||||
 *
 | 
			
		||||
 * 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 Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
			
		||||
 *
 | 
			
		||||
 * In addition, as a special exception, the copyright holders give
 | 
			
		||||
 * permission to link the code of portions of this program with the
 | 
			
		||||
 * OpenSSL library under certain conditions as described in each
 | 
			
		||||
 * individual source file, and distribute linked combinations
 | 
			
		||||
 * including the two.
 | 
			
		||||
 * You must obey the GNU General Public License in all respects
 | 
			
		||||
 * for all of the code used other than OpenSSL.  If you modify
 | 
			
		||||
 * file(s) with this exception, you may extend this exception to your
 | 
			
		||||
 * version of the file(s), but you are not obligated to do so.  If you
 | 
			
		||||
 * do not wish to do so, delete this exception statement from your
 | 
			
		||||
 * version.  If you delete this exception statement from all source
 | 
			
		||||
 * files in the program, then also delete it here.
 | 
			
		||||
 */
 | 
			
		||||
/* copyright --> */
 | 
			
		||||
#include "CopyDiskAdaptor.h"
 | 
			
		||||
#include "FileEntry.h"
 | 
			
		||||
#include "Logger.h"
 | 
			
		||||
#include "Util.h"
 | 
			
		||||
#include "message.h"
 | 
			
		||||
#include "File.h"
 | 
			
		||||
 | 
			
		||||
namespace aria2 {
 | 
			
		||||
 | 
			
		||||
void CopyDiskAdaptor::onDownloadComplete()
 | 
			
		||||
{
 | 
			
		||||
  closeFile();
 | 
			
		||||
  fixFilename();
 | 
			
		||||
  openFile();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CopyDiskAdaptor::fixFilename()
 | 
			
		||||
{
 | 
			
		||||
  off_t offset = 0;
 | 
			
		||||
  for(FileEntries::iterator itr = fileEntries.begin();
 | 
			
		||||
      itr != fileEntries.end(); itr++) {
 | 
			
		||||
    if(!(*itr)->isExtracted() && (*itr)->isRequested()) {
 | 
			
		||||
      (*itr)->setupDir();
 | 
			
		||||
      std::string destFilePath = (*itr)->getPath();
 | 
			
		||||
      logger->info(MSG_WRITING_FILE, destFilePath.c_str());
 | 
			
		||||
      Util::rangedFileCopy(destFilePath, getFilePath(),
 | 
			
		||||
			   offset, (*itr)->getLength());
 | 
			
		||||
      (*itr)->setExtracted(true);
 | 
			
		||||
    }
 | 
			
		||||
    offset += (*itr)->getLength();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string CopyDiskAdaptor::getFilePath()
 | 
			
		||||
{
 | 
			
		||||
  return storeDir+"/"+tempFilename;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t CopyDiskAdaptor::utime(const Time& actime, const Time& modtime)
 | 
			
		||||
{
 | 
			
		||||
  size_t numOK = 0;
 | 
			
		||||
  for(std::deque<SharedHandle<FileEntry> >::const_iterator i =
 | 
			
		||||
	fileEntries.begin(); i != fileEntries.end(); ++i) {
 | 
			
		||||
    if((*i)->isExtracted() && (*i)->isRequested()) {
 | 
			
		||||
      File f((*i)->getPath());
 | 
			
		||||
      if(f.isFile() && f.utime(actime, modtime)) {
 | 
			
		||||
	++numOK;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return numOK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace aria2
 | 
			
		||||
| 
						 | 
				
			
			@ -1,79 +0,0 @@
 | 
			
		|||
/* <!-- copyright */
 | 
			
		||||
/*
 | 
			
		||||
 * aria2 - The high speed download utility
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2006 Tatsuhiro Tsujikawa
 | 
			
		||||
 *
 | 
			
		||||
 * 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 Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
			
		||||
 *
 | 
			
		||||
 * In addition, as a special exception, the copyright holders give
 | 
			
		||||
 * permission to link the code of portions of this program with the
 | 
			
		||||
 * OpenSSL library under certain conditions as described in each
 | 
			
		||||
 * individual source file, and distribute linked combinations
 | 
			
		||||
 * including the two.
 | 
			
		||||
 * You must obey the GNU General Public License in all respects
 | 
			
		||||
 * for all of the code used other than OpenSSL.  If you modify
 | 
			
		||||
 * file(s) with this exception, you may extend this exception to your
 | 
			
		||||
 * version of the file(s), but you are not obligated to do so.  If you
 | 
			
		||||
 * do not wish to do so, delete this exception statement from your
 | 
			
		||||
 * version.  If you delete this exception statement from all source
 | 
			
		||||
 * files in the program, then also delete it here.
 | 
			
		||||
 */
 | 
			
		||||
/* copyright --> */
 | 
			
		||||
#ifndef _D_COPY_DISK_ADAPTOR_H_
 | 
			
		||||
#define _D_COPY_DISK_ADAPTOR_H_
 | 
			
		||||
 | 
			
		||||
#include "AbstractSingleDiskAdaptor.h"
 | 
			
		||||
 | 
			
		||||
namespace aria2 {
 | 
			
		||||
 | 
			
		||||
class CopyDiskAdaptor : public AbstractSingleDiskAdaptor {
 | 
			
		||||
private:
 | 
			
		||||
  std::string tempFilename;
 | 
			
		||||
  std::string topDir;
 | 
			
		||||
 | 
			
		||||
  void fixFilename();
 | 
			
		||||
public:
 | 
			
		||||
  CopyDiskAdaptor() {}
 | 
			
		||||
 | 
			
		||||
  virtual ~CopyDiskAdaptor() {}
 | 
			
		||||
 | 
			
		||||
  virtual std::string getFilePath();
 | 
			
		||||
 | 
			
		||||
  virtual void onDownloadComplete();
 | 
			
		||||
 | 
			
		||||
  virtual size_t utime(const Time& actime, const Time& modtime);
 | 
			
		||||
 | 
			
		||||
  // tempFilename is relative to storeDir
 | 
			
		||||
  void setTempFilename(const std::string& tempFilename) {
 | 
			
		||||
    this->tempFilename = tempFilename;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const std::string& getTempFile() const { return this->tempFilename; }
 | 
			
		||||
 | 
			
		||||
  void setTopDir(const std::string& topDir) {
 | 
			
		||||
    this->topDir = topDir;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const std::string& getTopDir() const {
 | 
			
		||||
    return topDir;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef SharedHandle<CopyDiskAdaptor> CopyDiskAdaptorHandle;
 | 
			
		||||
 | 
			
		||||
} // namespace aria2
 | 
			
		||||
 | 
			
		||||
#endif // _D_COPY_DISK_ADAPTOR_H_
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,6 @@
 | 
			
		|||
#include "prefs.h"
 | 
			
		||||
#include "DirectDiskAdaptor.h"
 | 
			
		||||
#include "MultiDiskAdaptor.h"
 | 
			
		||||
#include "CopyDiskAdaptor.h"
 | 
			
		||||
#include "DiskWriter.h"
 | 
			
		||||
#include "BitfieldManFactory.h"
 | 
			
		||||
#include "BitfieldMan.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -490,23 +489,12 @@ void DefaultPieceStorage::initStorage()
 | 
			
		|||
    this->diskAdaptor = directDiskAdaptor;
 | 
			
		||||
  } else {
 | 
			
		||||
    // file mode == DownloadContext::MULTI
 | 
			
		||||
    if(option->getAsBool(PREF_DIRECT_FILE_MAPPING)) {
 | 
			
		||||
    logger->debug("Instantiating MultiDiskAdaptor");
 | 
			
		||||
    MultiDiskAdaptorHandle multiDiskAdaptor(new MultiDiskAdaptor());
 | 
			
		||||
    multiDiskAdaptor->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
 | 
			
		||||
    multiDiskAdaptor->setPieceLength(downloadContext->getPieceLength());
 | 
			
		||||
    multiDiskAdaptor->setMaxOpenFiles(option->getAsInt(PREF_BT_MAX_OPEN_FILES));
 | 
			
		||||
    this->diskAdaptor = multiDiskAdaptor;
 | 
			
		||||
    } else {
 | 
			
		||||
      logger->debug("Instantiating CopyDiskAdaptor");
 | 
			
		||||
      DiskWriterHandle writer = _diskWriterFactory->newDiskWriter();
 | 
			
		||||
      writer->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
 | 
			
		||||
      CopyDiskAdaptorHandle copyDiskAdaptor(new CopyDiskAdaptor());
 | 
			
		||||
      copyDiskAdaptor->setDiskWriter(writer);
 | 
			
		||||
      //copyDiskAdaptor->setTempFilename(downloadContext->getName()+".a2tmp");
 | 
			
		||||
      copyDiskAdaptor->setTotalLength(downloadContext->getTotalLength());
 | 
			
		||||
      this->diskAdaptor = copyDiskAdaptor;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  diskAdaptor->setStoreDir(downloadContext->getDir());
 | 
			
		||||
  diskAdaptor->setFileEntries(downloadContext->getFileEntries());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -142,7 +142,6 @@ SRCS =  Socket.h\
 | 
			
		|||
	IteratableValidator.h\
 | 
			
		||||
	DiskAdaptor.cc DiskAdaptor.h\
 | 
			
		||||
	AbstractSingleDiskAdaptor.cc AbstractSingleDiskAdaptor.h\
 | 
			
		||||
	CopyDiskAdaptor.cc CopyDiskAdaptor.h\
 | 
			
		||||
	DirectDiskAdaptor.cc DirectDiskAdaptor.h\
 | 
			
		||||
	MultiDiskAdaptor.cc MultiDiskAdaptor.h\
 | 
			
		||||
	Peer.cc\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -382,19 +382,18 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
 | 
			
		|||
	StreamCheckIntegrityEntry.cc StreamCheckIntegrityEntry.h \
 | 
			
		||||
	IteratableValidator.h DiskAdaptor.cc DiskAdaptor.h \
 | 
			
		||||
	AbstractSingleDiskAdaptor.cc AbstractSingleDiskAdaptor.h \
 | 
			
		||||
	CopyDiskAdaptor.cc CopyDiskAdaptor.h DirectDiskAdaptor.cc \
 | 
			
		||||
	DirectDiskAdaptor.h MultiDiskAdaptor.cc MultiDiskAdaptor.h \
 | 
			
		||||
	Peer.cc PeerSessionResource.cc PeerSessionResource.h \
 | 
			
		||||
	BtRegistry.cc BtRegistry.h MultiFileAllocationIterator.cc \
 | 
			
		||||
	MultiFileAllocationIterator.h PeerConnection.cc \
 | 
			
		||||
	PeerConnection.h ByteArrayDiskWriter.cc ByteArrayDiskWriter.h \
 | 
			
		||||
	ByteArrayDiskWriterFactory.cc ByteArrayDiskWriterFactory.h \
 | 
			
		||||
	ServerHost.cc ServerHost.h DownloadContext.cc \
 | 
			
		||||
	DownloadContext.h SingleFileDownloadContext.cc \
 | 
			
		||||
	SingleFileDownloadContext.h TimedHaltCommand.cc \
 | 
			
		||||
	TimedHaltCommand.h CUIDCounter.h DNSCache.h DownloadResult.h \
 | 
			
		||||
	Sequence.h IntSequence.h PostDownloadHandler.h \
 | 
			
		||||
	PreDownloadHandler.h SingletonHolder.h \
 | 
			
		||||
	DirectDiskAdaptor.cc DirectDiskAdaptor.h MultiDiskAdaptor.cc \
 | 
			
		||||
	MultiDiskAdaptor.h Peer.cc PeerSessionResource.cc \
 | 
			
		||||
	PeerSessionResource.h BtRegistry.cc BtRegistry.h \
 | 
			
		||||
	MultiFileAllocationIterator.cc MultiFileAllocationIterator.h \
 | 
			
		||||
	PeerConnection.cc PeerConnection.h ByteArrayDiskWriter.cc \
 | 
			
		||||
	ByteArrayDiskWriter.h ByteArrayDiskWriterFactory.cc \
 | 
			
		||||
	ByteArrayDiskWriterFactory.h ServerHost.cc ServerHost.h \
 | 
			
		||||
	DownloadContext.cc DownloadContext.h \
 | 
			
		||||
	SingleFileDownloadContext.cc SingleFileDownloadContext.h \
 | 
			
		||||
	TimedHaltCommand.cc TimedHaltCommand.h CUIDCounter.h \
 | 
			
		||||
	DNSCache.h DownloadResult.h Sequence.h IntSequence.h \
 | 
			
		||||
	PostDownloadHandler.h PreDownloadHandler.h SingletonHolder.h \
 | 
			
		||||
	TrueRequestGroupCriteria.h a2algo.h a2functional.h a2io.h \
 | 
			
		||||
	a2netcompat.h a2time.h array_fun.h help_tags.h prefs.cc \
 | 
			
		||||
	prefs.h usage_text.h ProtocolDetector.cc ProtocolDetector.h \
 | 
			
		||||
| 
						 | 
				
			
			@ -795,7 +794,7 @@ am__objects_22 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
 | 
			
		|||
	CheckIntegrityEntry.$(OBJEXT) \
 | 
			
		||||
	PieceHashCheckIntegrityEntry.$(OBJEXT) \
 | 
			
		||||
	StreamCheckIntegrityEntry.$(OBJEXT) DiskAdaptor.$(OBJEXT) \
 | 
			
		||||
	AbstractSingleDiskAdaptor.$(OBJEXT) CopyDiskAdaptor.$(OBJEXT) \
 | 
			
		||||
	AbstractSingleDiskAdaptor.$(OBJEXT) \
 | 
			
		||||
	DirectDiskAdaptor.$(OBJEXT) MultiDiskAdaptor.$(OBJEXT) \
 | 
			
		||||
	Peer.$(OBJEXT) PeerSessionResource.$(OBJEXT) \
 | 
			
		||||
	BtRegistry.$(OBJEXT) MultiFileAllocationIterator.$(OBJEXT) \
 | 
			
		||||
| 
						 | 
				
			
			@ -1118,19 +1117,18 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
 | 
			
		|||
	StreamCheckIntegrityEntry.cc StreamCheckIntegrityEntry.h \
 | 
			
		||||
	IteratableValidator.h DiskAdaptor.cc DiskAdaptor.h \
 | 
			
		||||
	AbstractSingleDiskAdaptor.cc AbstractSingleDiskAdaptor.h \
 | 
			
		||||
	CopyDiskAdaptor.cc CopyDiskAdaptor.h DirectDiskAdaptor.cc \
 | 
			
		||||
	DirectDiskAdaptor.h MultiDiskAdaptor.cc MultiDiskAdaptor.h \
 | 
			
		||||
	Peer.cc PeerSessionResource.cc PeerSessionResource.h \
 | 
			
		||||
	BtRegistry.cc BtRegistry.h MultiFileAllocationIterator.cc \
 | 
			
		||||
	MultiFileAllocationIterator.h PeerConnection.cc \
 | 
			
		||||
	PeerConnection.h ByteArrayDiskWriter.cc ByteArrayDiskWriter.h \
 | 
			
		||||
	ByteArrayDiskWriterFactory.cc ByteArrayDiskWriterFactory.h \
 | 
			
		||||
	ServerHost.cc ServerHost.h DownloadContext.cc \
 | 
			
		||||
	DownloadContext.h SingleFileDownloadContext.cc \
 | 
			
		||||
	SingleFileDownloadContext.h TimedHaltCommand.cc \
 | 
			
		||||
	TimedHaltCommand.h CUIDCounter.h DNSCache.h DownloadResult.h \
 | 
			
		||||
	Sequence.h IntSequence.h PostDownloadHandler.h \
 | 
			
		||||
	PreDownloadHandler.h SingletonHolder.h \
 | 
			
		||||
	DirectDiskAdaptor.cc DirectDiskAdaptor.h MultiDiskAdaptor.cc \
 | 
			
		||||
	MultiDiskAdaptor.h Peer.cc PeerSessionResource.cc \
 | 
			
		||||
	PeerSessionResource.h BtRegistry.cc BtRegistry.h \
 | 
			
		||||
	MultiFileAllocationIterator.cc MultiFileAllocationIterator.h \
 | 
			
		||||
	PeerConnection.cc PeerConnection.h ByteArrayDiskWriter.cc \
 | 
			
		||||
	ByteArrayDiskWriter.h ByteArrayDiskWriterFactory.cc \
 | 
			
		||||
	ByteArrayDiskWriterFactory.h ServerHost.cc ServerHost.h \
 | 
			
		||||
	DownloadContext.cc DownloadContext.h \
 | 
			
		||||
	SingleFileDownloadContext.cc SingleFileDownloadContext.h \
 | 
			
		||||
	TimedHaltCommand.cc TimedHaltCommand.h CUIDCounter.h \
 | 
			
		||||
	DNSCache.h DownloadResult.h Sequence.h IntSequence.h \
 | 
			
		||||
	PostDownloadHandler.h PreDownloadHandler.h SingletonHolder.h \
 | 
			
		||||
	TrueRequestGroupCriteria.h a2algo.h a2functional.h a2io.h \
 | 
			
		||||
	a2netcompat.h a2time.h array_fun.h help_tags.h prefs.cc \
 | 
			
		||||
	prefs.h usage_text.h ProtocolDetector.cc ProtocolDetector.h \
 | 
			
		||||
| 
						 | 
				
			
			@ -1312,7 +1310,6 @@ distclean-compile:
 | 
			
		|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cookie.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieParser.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieStorage.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CopyDiskAdaptor.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DHTAbstractMessage.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DHTAbstractNodeLookupTask.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DHTAbstractTask.Po@am__quote@
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -922,14 +922,6 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
 | 
			
		|||
    op->hide();
 | 
			
		||||
    handlers.push_back(op);
 | 
			
		||||
  }
 | 
			
		||||
  {
 | 
			
		||||
    SharedHandle<OptionHandler> op(new BooleanOptionHandler
 | 
			
		||||
				   (PREF_DIRECT_FILE_MAPPING,
 | 
			
		||||
				    TEXT_DIRECT_FILE_MAPPING,
 | 
			
		||||
				    V_TRUE));
 | 
			
		||||
    op->addTag(TAG_BITTORRENT);
 | 
			
		||||
    handlers.push_back(op);
 | 
			
		||||
  }
 | 
			
		||||
  {
 | 
			
		||||
    SharedHandle<OptionHandler> op(new HostPortOptionHandler
 | 
			
		||||
				   (PREF_DHT_ENTRY_POINT,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -233,8 +233,6 @@ const std::string PREF_BT_TIMEOUT("bt-timeout");
 | 
			
		|||
const std::string PREF_BT_REQUEST_TIMEOUT("bt-request-timeout");
 | 
			
		||||
// values: true | false
 | 
			
		||||
const std::string PREF_SHOW_FILES("show-files");
 | 
			
		||||
// values: true | false
 | 
			
		||||
const std::string PREF_DIRECT_FILE_MAPPING("direct-file-mapping");
 | 
			
		||||
// values: 1*digit
 | 
			
		||||
const std::string PREF_MAX_OVERALL_UPLOAD_LIMIT("max-overall-upload-limit");
 | 
			
		||||
// values: 1*digit
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -237,8 +237,6 @@ extern const std::string PREF_BT_TIMEOUT;
 | 
			
		|||
extern const std::string PREF_BT_REQUEST_TIMEOUT;
 | 
			
		||||
// values: true | false
 | 
			
		||||
extern const std::string PREF_SHOW_FILES;
 | 
			
		||||
// values: true | false
 | 
			
		||||
extern const std::string PREF_DIRECT_FILE_MAPPING;
 | 
			
		||||
// values: 1*digit
 | 
			
		||||
extern const std::string PREF_MAX_OVERALL_UPLOAD_LIMIT;
 | 
			
		||||
// values: 1*digit
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -233,9 +233,6 @@ _(" --follow-torrent=true|false|mem If true or mem is specified, when a file\n"\
 | 
			
		|||
  "                              written to the disk, but is just kept in memory.\n"\
 | 
			
		||||
  "                              If false is specified, the action mentioned above\n"\
 | 
			
		||||
  "                              is not taken.")
 | 
			
		||||
#define TEXT_DIRECT_FILE_MAPPING \
 | 
			
		||||
_(" --direct-file-mapping=true|false Directly read from and write to each file\n"\
 | 
			
		||||
  "                              mentioned in .torrent file.")
 | 
			
		||||
#define TEXT_LISTEN_PORT \
 | 
			
		||||
_(" --listen-port=PORT...        Set TCP port number for BitTorrent downloads.\n"\
 | 
			
		||||
  "                              Multiple ports can be specified by using ',',\n"\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,79 +0,0 @@
 | 
			
		|||
#include "CopyDiskAdaptor.h"
 | 
			
		||||
#include "FileEntry.h"
 | 
			
		||||
#include "Exception.h"
 | 
			
		||||
#include "a2io.h"
 | 
			
		||||
#include "array_fun.h"
 | 
			
		||||
#include "TestUtil.h"
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <cerrno>
 | 
			
		||||
#include <cstring>
 | 
			
		||||
#include <cppunit/extensions/HelperMacros.h>
 | 
			
		||||
 | 
			
		||||
namespace aria2 {
 | 
			
		||||
 | 
			
		||||
class CopyDiskAdaptorTest:public CppUnit::TestFixture {
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_TEST_SUITE(CopyDiskAdaptorTest);
 | 
			
		||||
  CPPUNIT_TEST(testUtime);
 | 
			
		||||
  CPPUNIT_TEST_SUITE_END();
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  void setUp() {}
 | 
			
		||||
 | 
			
		||||
  void testUtime();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CPPUNIT_TEST_SUITE_REGISTRATION( CopyDiskAdaptorTest );
 | 
			
		||||
 | 
			
		||||
void CopyDiskAdaptorTest::testUtime()
 | 
			
		||||
{
 | 
			
		||||
  std::string storeDir = "/tmp/aria2_CopyDiskAdaptorTest_testUtime";
 | 
			
		||||
  SharedHandle<FileEntry> entries[] = {
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(storeDir+"/requested", 10, 0)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(storeDir+"/notFound", 10, 10)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(storeDir+"/notRequested", 10, 20)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(storeDir+"/notExtracted", 10, 30)),
 | 
			
		||||
    SharedHandle<FileEntry>(new FileEntry(storeDir+"/anotherRequested", 10, 40)),
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  std::deque<SharedHandle<FileEntry> > fileEntries
 | 
			
		||||
    (&entries[0], &entries[arrayLength(entries)]);
 | 
			
		||||
  CopyDiskAdaptor adaptor;
 | 
			
		||||
  adaptor.setStoreDir(storeDir);
 | 
			
		||||
  adaptor.setFileEntries(fileEntries);
 | 
			
		||||
 | 
			
		||||
  entries[0]->setExtracted(true);
 | 
			
		||||
  entries[1]->setExtracted(true);
 | 
			
		||||
  entries[2]->setExtracted(true);
 | 
			
		||||
  entries[4]->setExtracted(true);
 | 
			
		||||
  
 | 
			
		||||
  entries[2]->setRequested(false);
 | 
			
		||||
 | 
			
		||||
  createFile(entries[0]->getPath(), entries[0]->getLength());
 | 
			
		||||
  File(entries[1]->getPath()).remove();
 | 
			
		||||
  createFile(entries[2]->getPath(), entries[2]->getLength());
 | 
			
		||||
  createFile(entries[3]->getPath(), entries[3]->getLength());
 | 
			
		||||
  createFile(entries[4]->getPath(), entries[4]->getLength());
 | 
			
		||||
 | 
			
		||||
  time_t atime = (time_t) 100000;
 | 
			
		||||
  time_t mtime = (time_t) 200000;
 | 
			
		||||
  
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)2, adaptor.utime(Time(atime), Time(mtime)));
 | 
			
		||||
  
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((time_t)mtime,
 | 
			
		||||
		       File(entries[0]->getPath()).getModifiedTime().getTime());
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((time_t)mtime,
 | 
			
		||||
		       File(entries[4]->getPath()).getModifiedTime().getTime());
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT((time_t)mtime !=
 | 
			
		||||
		 File(entries[1]->getPath()).getModifiedTime().getTime());
 | 
			
		||||
  CPPUNIT_ASSERT((time_t)mtime !=
 | 
			
		||||
		 File(entries[2]->getPath()).getModifiedTime().getTime());
 | 
			
		||||
  CPPUNIT_ASSERT((time_t)mtime !=
 | 
			
		||||
		 File(entries[3]->getPath()).getModifiedTime().getTime());
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace aria2
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +59,6 @@ aria2c_SOURCES = AllTest.cc\
 | 
			
		|||
	CookieTest.cc\
 | 
			
		||||
	CookieStorageTest.cc\
 | 
			
		||||
	TimeTest.cc\
 | 
			
		||||
	CopyDiskAdaptorTest.cc\
 | 
			
		||||
	FtpConnectionTest.cc\
 | 
			
		||||
	OptionParserTest.cc\
 | 
			
		||||
	SimpleDNSCacheTest.cc\
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -189,11 +189,11 @@ am__aria2c_SOURCES_DIST = AllTest.cc TestUtil.cc TestUtil.h \
 | 
			
		|||
	ServerStatURISelectorTest.cc InOrderURISelectorTest.cc \
 | 
			
		||||
	ServerStatTest.cc NsCookieParserTest.cc \
 | 
			
		||||
	DirectDiskAdaptorTest.cc CookieTest.cc CookieStorageTest.cc \
 | 
			
		||||
	TimeTest.cc CopyDiskAdaptorTest.cc FtpConnectionTest.cc \
 | 
			
		||||
	OptionParserTest.cc SimpleDNSCacheTest.cc \
 | 
			
		||||
	DownloadHelperTest.cc BencodeTest.cc SequentialPickerTest.cc \
 | 
			
		||||
	RarestPieceSelectorTest.cc LongestSequencePieceSelectorTest.cc \
 | 
			
		||||
	a2algoTest.cc GZipDecoderTest.cc Sqlite3MozCookieParserTest.cc \
 | 
			
		||||
	TimeTest.cc FtpConnectionTest.cc OptionParserTest.cc \
 | 
			
		||||
	SimpleDNSCacheTest.cc DownloadHelperTest.cc BencodeTest.cc \
 | 
			
		||||
	SequentialPickerTest.cc RarestPieceSelectorTest.cc \
 | 
			
		||||
	LongestSequencePieceSelectorTest.cc a2algoTest.cc \
 | 
			
		||||
	GZipDecoderTest.cc Sqlite3MozCookieParserTest.cc \
 | 
			
		||||
	MessageDigestHelperTest.cc \
 | 
			
		||||
	IteratableChunkChecksumValidatorTest.cc \
 | 
			
		||||
	IteratableChecksumValidatorTest.cc BtAllowedFastMessageTest.cc \
 | 
			
		||||
| 
						 | 
				
			
			@ -357,10 +357,10 @@ am_aria2c_OBJECTS = AllTest.$(OBJEXT) TestUtil.$(OBJEXT) \
 | 
			
		|||
	InOrderURISelectorTest.$(OBJEXT) ServerStatTest.$(OBJEXT) \
 | 
			
		||||
	NsCookieParserTest.$(OBJEXT) DirectDiskAdaptorTest.$(OBJEXT) \
 | 
			
		||||
	CookieTest.$(OBJEXT) CookieStorageTest.$(OBJEXT) \
 | 
			
		||||
	TimeTest.$(OBJEXT) CopyDiskAdaptorTest.$(OBJEXT) \
 | 
			
		||||
	FtpConnectionTest.$(OBJEXT) OptionParserTest.$(OBJEXT) \
 | 
			
		||||
	SimpleDNSCacheTest.$(OBJEXT) DownloadHelperTest.$(OBJEXT) \
 | 
			
		||||
	BencodeTest.$(OBJEXT) SequentialPickerTest.$(OBJEXT) \
 | 
			
		||||
	TimeTest.$(OBJEXT) FtpConnectionTest.$(OBJEXT) \
 | 
			
		||||
	OptionParserTest.$(OBJEXT) SimpleDNSCacheTest.$(OBJEXT) \
 | 
			
		||||
	DownloadHelperTest.$(OBJEXT) BencodeTest.$(OBJEXT) \
 | 
			
		||||
	SequentialPickerTest.$(OBJEXT) \
 | 
			
		||||
	RarestPieceSelectorTest.$(OBJEXT) \
 | 
			
		||||
	LongestSequencePieceSelectorTest.$(OBJEXT) \
 | 
			
		||||
	a2algoTest.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
 | 
			
		||||
| 
						 | 
				
			
			@ -585,11 +585,11 @@ aria2c_SOURCES = AllTest.cc TestUtil.cc TestUtil.h SocketCoreTest.cc \
 | 
			
		|||
	ServerStatURISelectorTest.cc InOrderURISelectorTest.cc \
 | 
			
		||||
	ServerStatTest.cc NsCookieParserTest.cc \
 | 
			
		||||
	DirectDiskAdaptorTest.cc CookieTest.cc CookieStorageTest.cc \
 | 
			
		||||
	TimeTest.cc CopyDiskAdaptorTest.cc FtpConnectionTest.cc \
 | 
			
		||||
	OptionParserTest.cc SimpleDNSCacheTest.cc \
 | 
			
		||||
	DownloadHelperTest.cc BencodeTest.cc SequentialPickerTest.cc \
 | 
			
		||||
	RarestPieceSelectorTest.cc LongestSequencePieceSelectorTest.cc \
 | 
			
		||||
	a2algoTest.cc $(am__append_1) $(am__append_2) $(am__append_3) \
 | 
			
		||||
	TimeTest.cc FtpConnectionTest.cc OptionParserTest.cc \
 | 
			
		||||
	SimpleDNSCacheTest.cc DownloadHelperTest.cc BencodeTest.cc \
 | 
			
		||||
	SequentialPickerTest.cc RarestPieceSelectorTest.cc \
 | 
			
		||||
	LongestSequencePieceSelectorTest.cc a2algoTest.cc \
 | 
			
		||||
	$(am__append_1) $(am__append_2) $(am__append_3) \
 | 
			
		||||
	$(am__append_4) $(am__append_5)
 | 
			
		||||
 | 
			
		||||
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
 | 
			
		||||
| 
						 | 
				
			
			@ -714,7 +714,6 @@ distclean-compile:
 | 
			
		|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieParserTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieStorageTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CopyDiskAdaptorTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DHKeyExchangeTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DHTAnnouncePeerMessageTest.Po@am__quote@
 | 
			
		||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DHTAnnouncePeerReplyMessageTest.Po@am__quote@
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue