[go: up one dir, main page]

Menu

[461a73]: / io / create_file.cpp  Maximize  Restore  History

Download this file

112 lines (104 with data), 3.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
/***************************************************************************
* io/create_file.cpp
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2002 Roman Dementiev <dementiev@mpi-sb.mpg.de>
* Copyright (C) 2008, 2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
* Copyright (C) 2008, 2009 Johannes Singler <singler@ira.uka.de>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#include <stxxl/bits/io/create_file.h>
#include <stxxl/bits/io/io.h>
__STXXL_BEGIN_NAMESPACE
file * create_file(const std::string & io_impl,
const std::string & filename,
int options, int physical_device_id, int allocator_id)
{
if (io_impl == "syscall")
{
ufs_file_base * result = new syscall_file(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
else if (io_impl == "fileperblock_syscall")
{
fileperblock_file<syscall_file> * result = new fileperblock_file<syscall_file>(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
#if STXXL_HAVE_MMAP_FILE
else if (io_impl == "mmap")
{
ufs_file_base * result = new mmap_file(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
else if (io_impl == "fileperblock_mmap")
{
fileperblock_file<mmap_file> * result = new fileperblock_file<mmap_file>(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
#endif
#if STXXL_HAVE_SIMDISK_FILE
else if (io_impl == "simdisk")
{
options &= ~stxxl::file::DIRECT; // clear the DIRECT flag, this file is supposed to be on tmpfs
ufs_file_base * result = new sim_disk_file(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
#endif
#if STXXL_HAVE_WINCALL_FILE
else if (io_impl == "wincall")
{
wfs_file_base * result = new wincall_file(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
else if (io_impl == "fileperblock_wincall")
{
fileperblock_file<wincall_file> * result = new fileperblock_file<wincall_file>(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
#endif
#if STXXL_HAVE_BOOSTFD_FILE
else if (io_impl == "boostfd")
{
boostfd_file * result = new boostfd_file(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
else if (io_impl == "fileperblock_boostfd")
{
fileperblock_file<boostfd_file> * result = new fileperblock_file<boostfd_file>(filename, options, physical_device_id, allocator_id);
result->lock();
return result;
}
#endif
else if (io_impl == "memory")
{
mem_file * result = new mem_file(physical_device_id, allocator_id);
result->lock();
return result;
}
#if STXXL_HAVE_WBTL_FILE
else if (io_impl == "wbtl")
{
ufs_file_base * backend = new syscall_file(filename, options, -1, -1); // FIXME: ID
wbtl_file * result = new stxxl::wbtl_file(backend, 16 * 1024 * 1024, 2, physical_device_id, allocator_id);
result->lock();
return result;
}
#endif
STXXL_THROW(std::runtime_error, "FileCreator::create", "Unsupported disk I/O implementation " <<
io_impl << " .");
return NULL;
}
__STXXL_END_NAMESPACE
// vim: et:ts=4:sw=4