bungle / lua-resty-fileinfo

LuaJIT FFI bindings to libmagic, magic number recognition library - tries to determine file types.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

relative path supported?

nly opened this issue · comments

I use this library and a little confused about the path. I use relative path it says "cannot open xxx",as I try to use a absolute path it says "ASCII text".

Hi, thanks I will look at it.

Well, I'm not sure what you mean, maybe you have a problem about what path you are relative to? I tried a few paths and it worked just fine. Can you make a full example?

Yes, it seems to be relative to nginx binary, and that is by default:

/usr/local/openresty/nginx/sbin/

We can add the ngx.var.document_root to it by default if we want. What do you think. One problem about ngx.var is that it is not available in all contexts.

Or even better relative to file that is executing. But for that you have to use debug-library, and that's not very pretty. As far as I know.

Maybe you could just write your own:

local function getfullpath(relative)
   -- ...
end

Yes , I use ngx.var.document_root as the root_path varible in my project, works well.