1/* Part of SWI-Prolog 2 3 Author: Jan Wielemaker 4 E-mail: J.Wielemaker@vu.nl 5 WWW: http://www.swi-prolog.org 6 Copyright (c) 2001-2020, University of Amsterdam 7 CWI, Amsterdam 8 All rights reserved. 9 10 Redistribution and use in source and binary forms, with or without 11 modification, are permitted provided that the following conditions 12 are met: 13 14 1. Redistributions of source code must retain the above copyright 15 notice, this list of conditions and the following disclaimer. 16 17 2. Redistributions in binary form must reproduce the above copyright 18 notice, this list of conditions and the following disclaimer in 19 the documentation and/or other materials provided with the 20 distribution. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 POSSIBILITY OF SUCH DAMAGE. 34*/ 35 36:- module(memory_file, 37 [ new_memory_file/1, % -Handle 38 free_memory_file/1, % +Handle 39 size_memory_file/2, % +Handle, -Size 40 size_memory_file/3, % +Handle, -Size, +Encoding 41 open_memory_file/3, % +Handle, +Mode, -Stream 42 open_memory_file/4, % +Handle, +Mode, -Stream, +Options 43 insert_memory_file/3, % +Handle, +Position, +Data 44 delete_memory_file/3, % +Handle, +Position, +Length 45 atom_to_memory_file/2, % +Atom, -Handle 46 memory_file_to_atom/2, % +Handle, -Atom 47 memory_file_to_codes/2, % +Handle, -CodeList 48 memory_file_to_string/2, % +Handle, -String 49 memory_file_to_atom/3, % +Handle, -Atom, +Encoding 50 memory_file_to_codes/3, % +Handle, -CodeList, +Encoding 51 memory_file_to_string/3, % +Handle, -String, +Encoding 52 memory_file_substring/5, % +Handle, +Before, +Length, +After, -String 53 memory_file_line_position/4,% +Handle, ?Line, ?ListPos, ?Offset 54 utf8_position_memory_file/3 % +Handle, -Here, -Size 55 ]). 56:- use_foreign_library(foreign(memfile)). 57 58:- predicate_options(open_memory_file/4, 4, 59 [ encoding(encoding), 60 free_on_close(boolean) 61 ]).