Compare commits
2 Commits
7a6d182454
...
294e2f2d5b
Author | SHA1 | Date |
---|---|---|
The Magician | 294e2f2d5b | |
The Magician | 160b7509a2 |
|
@ -1 +1,2 @@
|
||||||
luacov.stats.out
|
luacov.stats.out
|
||||||
|
nextfile-0.0.1-1.src.rock
|
||||||
|
|
|
@ -3,8 +3,8 @@ local prevfile = require "prevfile"
|
||||||
local nextfile = {}
|
local nextfile = {}
|
||||||
|
|
||||||
function nextfile.splitfilename(path)
|
function nextfile.splitfilename(path)
|
||||||
dir, name, ext = path:match("^(.*/)(.*)(%.%w*)")
|
name, ext = path:match("^(.*)(%.%w*)")
|
||||||
return dir, name, ext
|
return name, ext
|
||||||
end
|
end
|
||||||
|
|
||||||
function nextfile.nextletter(letter)
|
function nextfile.nextletter(letter)
|
||||||
|
@ -19,9 +19,9 @@ function nextfile.nextfile(directory, extension)
|
||||||
local previous = prevfile.prevfile(directory)
|
local previous = prevfile.prevfile(directory)
|
||||||
if previous == nil then return nil end
|
if previous == nil then return nil end
|
||||||
|
|
||||||
local dir, name, ext = nextfile.splitfilename(previous)
|
local name, ext = nextfile.splitfilename(previous)
|
||||||
|
|
||||||
value = dir
|
value = ""
|
||||||
if tonumber(name) == nil then
|
if tonumber(name) == nil then
|
||||||
local lastletter = name:sub(#name)
|
local lastletter = name:sub(#name)
|
||||||
local nextletter = nextfile.nextletter(lastletter)
|
local nextletter = nextfile.nextletter(lastletter)
|
||||||
|
|
|
@ -1,21 +1,12 @@
|
||||||
describe("splitfilename", function()
|
describe("splitfilename", function()
|
||||||
local nextfile = require "nextfile"
|
local nextfile = require "nextfile"
|
||||||
|
|
||||||
it("should return the filename and extension of an absolute filepath", function()
|
it("should return the filename and extension of a filename", function()
|
||||||
local dir, name, ext = nextfile.splitfilename("/testdir/701.txt")
|
local name, ext = nextfile.splitfilename("701.txt")
|
||||||
|
|
||||||
assert.are.equal("/testdir/", dir)
|
|
||||||
assert.are.equal("701", name)
|
assert.are.equal("701", name)
|
||||||
assert.are.equal(".txt", ext)
|
assert.are.equal(".txt", ext)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("should return the filename and extension of a relative filepath", function()
|
|
||||||
local dir, name, ext = nextfile.splitfilename("../../foo/testdir/file.mp3")
|
|
||||||
|
|
||||||
assert.are.equal("../../foo/testdir/", dir)
|
|
||||||
assert.are.equal("file", name)
|
|
||||||
assert.are.equal(".mp3", ext)
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe("nextletter", function()
|
describe("nextletter", function()
|
||||||
|
|
Loading…
Reference in New Issue