diff --git a/include/egeoip.hrl b/include/egeoip.hrl index 593a997..1bc9542 100644 --- a/include/egeoip.hrl +++ b/include/egeoip.hrl @@ -1,3 +1,6 @@ +-ifndef(APPLICATION). +-define(APPLICATION, egeoip). +-endif. -define(GEOIP_COUNTRY_BEGIN, 16776960). -define(GEOIP_STATE_BEGIN_REV0, 16700000). -define(GEOIP_STATE_BEGIN_REV1, 16000000). diff --git a/src/egeoip.erl b/src/egeoip.erl index f0ad249..9c627c4 100644 --- a/src/egeoip.erl +++ b/src/egeoip.erl @@ -492,13 +492,12 @@ read_segments(Type, Data, Seek) when Type == ?GEOIP_CITY_EDITION_REV0; <<_:Seek/binary, Segments:Bits/little, _/binary>> = Data, Segments. - priv_path(Components) -> - AppDir = case code:which(?MODULE) of - cover_compiled -> ".."; - F -> filename:dirname(filename:dirname(F)) - end, - filename:join([AppDir, "priv" | Components]). + PrivDir = case code:priv_dir(?APPLICATION) of + {error, _} -> "./priv"; + Dir -> Dir + end, + filename:join([PrivDir | Components]). load_file(Path) -> case file:read_file(Path) of