Skip to content

Commit 0e88988

Browse files
committed
add File.Delete
1 parent dcfc6a5 commit 0e88988

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎CSharp.lua/CoreSystem.Lua/CoreSystem/DateTime.lua‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ local ostime = os.time
3434
local osdifftime = os.difftime
3535
local osdate = os.date
3636
local tonumber = tonumber
37+
local math = math
3738
local floor = math.floor
3839
local log10 = math.log10
40+
local modf = math.modf
3941

4042
--http://referencesource.microsoft.com/#mscorlib/system/datetime.cs
4143
local DateTime = {}
@@ -414,7 +416,7 @@ local function parse(s)
414416
milliseconds = milliseconds / (10 ^ (n - 3))
415417
else
416418
local ticks = milliseconds / (10 ^ (n - 7))
417-
local _, decimal = math.modf(ticks)
419+
local _, decimal = modf(ticks)
418420
if decimal > 0.5 then
419421
ticks = ticks + 1
420422
end

‎CSharp.lua/CoreSystem.Lua/CoreSystem/IO/File.lua‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ local each = System.each
2020

2121
local io = io
2222
local open = io.open
23+
local remove = os.remove
2324

2425
local IOException = System.define("System.IO.IOException", {
2526
__tostring = System.Exception.ToString,
@@ -94,4 +95,11 @@ function File.Exists(path)
9495
return file ~= nil
9596
end
9697

98+
function File.Delete(path)
99+
local ok, err = remove(path)
100+
if not ok then
101+
throw(IOException(err))
102+
end
103+
end
104+
97105
System.define("System.IO.File", File)

‎CSharp.lua/CoreSystem.Lua/CoreSystem/Type.lua‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ limitations under the License.
1717
local System = System
1818
local throw = System.throw
1919
local Object = System.Object
20-
local Char = System.Char
21-
local Int = System.Int
22-
local Double = System.Double
2320
local String = System.String
2421
local Boolean = System.Boolean
2522
local Delegate = System.Delegate

‎CSharp.lua/CoreSystem.Lua/Sample/test.lua‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ local function testIO()
296296
File.WriteAllText(path, s)
297297
local text = File.ReadAllText(path)
298298
assert(text == s)
299-
os.remove(path)
299+
File.Delete(path)
300300
end
301301

302302
local function testStringBuilder()
@@ -366,9 +366,9 @@ test(testDelegate, "Delegate")
366366
test(testLinq, "Linq")
367367
test(testGroupBy, "GroupBy")
368368
test(testType, "Type")
369-
--test(testNumCast, "NumCast")
370-
--test(testSplit, "testSplit")
371-
--test(testStringBuilder, "StringBuilder")
369+
test(testNumCast, "NumCast")
370+
test(testSplit, "testSplit")
371+
test(testStringBuilder, "StringBuilder")
372+
test(testIO, "IO")
372373
--test(testConsole, "Console")
373-
--test(testIO, "IO")
374374
--test(testAsync, "Async")

0 commit comments

Comments
 (0)