Skip to content

Commit a8fe6c2

Browse files
authored
Add files via upload
1 parent 8a6e80a commit a8fe6c2

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

foxfile.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
default = FoxFile
55
proname = PyFoxFile
66
includedef = true
7-
inmemfile = true
7+
useinmem = true
8+
usmemfd = true
89
usespoolfile = false
910
spoolfilesize = 4194304
1011
filebuffsize = 262144

foxfile.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"default": "FoxFile",
44
"proname": "PyFoxFile",
55
"includedef": true,
6-
"inmemfile": true,
6+
"useinmem": true,
7+
"usememfd": true,
78
"usespoolfile": false,
89
"spoolfilesize": 4194304,
910
"filebuffsize": 262144

pyfoxfile.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ def _is_printable(ch):
416416
__file_format_multi_dict__ = {}
417417
__file_format_default__ = "FoxFile"
418418
__include_defaults__ = True
419-
__use_inmemfile__ = True
419+
__use_inmem__ = True
420+
__use_memfd__ = True
420421
__use_spoolfile__ = False
421422
__use_spooldir__ = tempfile.gettempdir()
422423
BYTES_PER_KiB = 1024
@@ -462,7 +463,8 @@ def decode_unicode_escape(value):
462463
__file_format_default__ = decode_unicode_escape(config.get('config', 'default'))
463464
__program_name__ = decode_unicode_escape(config.get('config', 'proname'))
464465
__include_defaults__ = config.getboolean('config', 'includedef')
465-
__use_inmemfile__ = config.getboolean('config', 'inmemfile')
466+
__use_inmem__ = config.getboolean('config', 'useinmem')
467+
__use_memfd__ = config.getboolean('config', 'usememfd')
466468
__use_spoolfile__ = config.getboolean('config', 'usespoolfile')
467469
__spoolfile_size__ = config.getint('config', 'spoolfilesize')
468470
# Loop through all sections
@@ -556,8 +558,9 @@ def _get(section_dict, key, default=None):
556558
cfg_config = cfg.get('config', {}) or {}
557559
__file_format_default__ = decode_unicode_escape(_get(cfg_config, 'default', ''))
558560
__program_name__ = decode_unicode_escape(_get(cfg_config, 'proname', ''))
559-
__include_defaults__ = _to_bool(_get(cfg_config, 'includedef', False))
560-
__use_inmemfile__ = _to_bool(_get(cfg_config, 'inmemfile', False))
561+
__include_defaults__ = _to_bool(_get(cfg_config, 'includedef', True))
562+
__use_inmem__ = _to_bool(_get(cfg_config, 'useinmem', True))
563+
__use_memfd__ = _to_bool(_get(cfg_config, 'usememfd', True))
561564
__use_spoolfile__ = _to_bool(_get(cfg_config, 'usespoolfile', False))
562565
__spoolfile_size__ = _to_int(_get(cfg_config, 'spoolfilesize', DEFAULT_SPOOL_MAX))
563566

@@ -2059,9 +2062,9 @@ def _normalize_initial_data(data, isbytes, encoding, errors=None):
20592062

20602063

20612064
def MkTempFile(data=None,
2062-
inmem=__use_inmemfile__,
2065+
inmem=__use_inmem__, usememfd=__use_memfd__,
20632066
isbytes=True,
2064-
prefix="",
2067+
prefix=__program_name__,
20652068
delete=True,
20662069
encoding="utf-8",
20672070
newline=None, # text mode only; in-memory objects ignore newline semantics
@@ -2123,13 +2126,13 @@ def MkTempFile(data=None,
21232126
# -------- In-memory --------
21242127
if inmem:
21252128
# Use memfd only for bytes, and only where available (Linux, Python 3.8+)
2126-
if isbytes and hasattr(os, "memfd_create"):
2129+
if usememfd and isbytes and hasattr(os, "memfd_create"):
21272130
flags = 0
21282131
# Close-on-exec is almost always what you want for temps
21292132
if hasattr(os, "MFD_CLOEXEC"):
21302133
flags |= os.MFD_CLOEXEC
21312134

2132-
fd = os.memfd_create("MkTempFile", flags)
2135+
fd = os.memfd_create(prefix, flags)
21332136
# Binary read/write file-like object backed by RAM
21342137
f = os.fdopen(fd, "w+b")
21352138

0 commit comments

Comments
 (0)