I am trying to understand how Boost memory-bound files work. The following code works, it does what it should do, but the problem is that the file it creates is stored on disk (in the same directory of the executable file) instead of memory. Maybe there is a flag somewhere, but I could not find it ...Thank you in advance for any information!
#include <iostream> #include <string> #include <cstring> #include <boost/iostreams/device/mapped_file.hpp> using std::cout; using std::endl; int main(int argc, char** argv) { const int blockSize = 64; bool writer = false; if(argc > 1) { if(!strcmp(argv[1], "w")) writer = true; } boost::iostreams::mapped_file_params params; params.path = "map.dat"; // params.length = 1024; // default: all the file params.new_file_size = blockSize; if(writer) { cout << "Writer" << endl; params.mode = std::ios_base::out; } else { cout << "Reader" << endl; params.mode = std::ios_base::in; } boost::iostreams::mapped_file mf; mf.open(params); if(writer) { char *block = mf.data(); strcpy(block, "Test data block...\0"); cout << "Written: " << block << endl; } else { cout << "Reading: " << mf.const_data() << endl; } mf.close(); return 0; } /* Compiler options: -Wall -I$(PATH_BOOST_INCLUDE) -ggdb Linker options: -L$(PATH_BOOST_LIBS) -lboost_iostreams-mt -lboost_system-mt -lboost_filesystem-mt -DBOOST_FILESYSTEM_NO_DEPRECATED */
Used compiler: gcc 4.2.1Boost 1.41.0OS: MacOS X 10.6.2
Memory Mapping maps disk files to memory. To do this, there must be a file on disk!
: , - . http://www.boost.org/doc/libs/1_41_0/doc/html/interprocess/quick_guide.html
, , , . " ". Boost mmap Unix . .
mmap
, , , , . Linux - , , , , , .
ramdisk...
, . ramdisk. Linux tmpfs, , . , , , , .
tmpfs
, V- , . sys V 10- .
Source: https://habr.com/ru/post/1726178/More articles:Is there any library in .Net to do basic sound editing? - c #ASP.NET 3.5 Web Services - c #What are the main differences between Python and PHP? - pythonPOST method, Ajax and security? - jqueryPHP: convert date in seconds? - phpDatabase table partitioning in MySQL - sqlMySQL manipulation and recovery bit in PHP - phpI am trying to create an expert system and my user interface is prepared in .Net, and now I am ready to connect it to LISP - .netPHP: RegEx vs. ctype_ * - phpProduction and development environment synchronization - gitAll Articles