Skip to content

Commit f6796b8

Browse files
committed
unimportant
1 parent 6038aa9 commit f6796b8

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

bundle.lua

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
-- Written by Cosmin Apreutesei. Public Domain.
44

55
local ffi = require'ffi'
6+
local fs = require'fs'
67
local external_dir = require'package.exedir'
78
local BBIN_PREFIX = 'Bbin_'
89

@@ -42,7 +43,6 @@ local function canopen_blob(file)
4243
end
4344

4445
local function fs_open_blob(file)
45-
local fs = require'fs'
4646
local buf, sz = blob_data(file)
4747
if not buf then return nil end
4848
return fs.open_buffer(buf, sz)
@@ -95,7 +95,6 @@ function bundle.open_dir_listing(dir, s)
9595
end
9696

9797
local function fs_dir_blob(dir)
98-
local fs = require'fs'
9998
return bundle.open_dir_listing(dir, load_blob(dir))
10099
end
101100

@@ -111,11 +110,11 @@ local function load_file(file)
111110
end
112111

113112
local function mmap_file(file)
114-
local s = load_file(file)
115-
if not s then return end
116-
--TODO: use fs.mmap() here
117-
return {data = ffi.cast('const void*', s), size = #s,
118-
close = function() local _ = s; end}
113+
local m, err = fs.map(file)
114+
if not m then return nil, err end
115+
m.data = ffi.cast('const void*', m.addr)
116+
m.close = m.free
117+
return m
119118
end
120119

121120
local function canopen_file(file)
@@ -125,12 +124,10 @@ local function canopen_file(file)
125124
end
126125

127126
function fs_open_file(file)
128-
local fs = require'fs'
129127
return (fs.open(file))
130128
end
131129

132130
function fs_dir_file(dir)
133-
local fs = require'fs'
134131
if not fs.is(dir, 'dir') then return nil end
135132
return fs.dir(dir)
136133
end

bundle_test.lua

+1-7
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ local function test_load_all()
3535
print('ok ('..m..')')
3636
end
3737

38-
local function test_load_mysql()
39-
local mysql = require'mysql_connector'
40-
mysql.config()
41-
end
42-
4338
local platos = {Windows = 'mingw', Linux = 'linux', OSX = 'osx'}
4439
local function current_platform()
4540
return platos[ffi.os]..(ffi.abi'32bit' and '32' or '64')
@@ -82,7 +77,6 @@ local function test_dir()
8277
end
8378
end
8479

85-
test_load_all()
86-
test_load_mysql()
80+
--test_load_all()
8781
test_blob()
8882
test_dir()

csrc/bundle/luajit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
** LuaJIT frontend. Runs commands, scripts, read-eval-print (REPL) etc.
3-
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
3+
** Copyright (C) 2005-2021 Mike Pall. See Copyright Notice in luajit.h
44
**
55
** Major portions taken verbatim or adapted from the Lua interpreter.
66
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

0 commit comments

Comments
 (0)