Marcus

Marcus

Hello. I have a test that fails on GitHub under windows. I have no windows running. Could someone with window check:

iex(1)> File.mkdir("bar")
:ok
iex(2)> File.touch("baz")
:ok
iex(3)> File.exists?("bar/../baz")
true
iex(4)> File.exists?("baz/../bar")
false

It seems under windows File.exists? returns true for both calls.

Showing Posts 1 to 3

cmo

cmo

You have a file called baz and a directory called bar in the current directory and you’re checking if you a file called baz and a directory called bar in the current directory. Shouldn’t both return true?

If there’s a difference it will be around how the parent directory is resolved for a nonexistent directory, no?

Marcus

Marcus OP

Yes, the point is that we get a different result when the code runs on windows.

# on unix
false = File.exists?("baz/../bar")
# on windows
true = File.exists?("baz/../bar")

The question is whether this is expected.

al2o3cr

al2o3cr

The BEAM file server eventually calls get_full_path in win_prim_file.c to turn the input string into an absolute path and and resolve .. / UNC paths / etc:

https://github.com/erlang/otp/blob/eccc556e79f315d1f87c10fb46f2c4af50a63f20/erts/emulator/nifs/win32/win_prim_file.c#L122-L126

That uses the Win32 API GetFullPathNameW which specifically calls out this kind of situation in its docs:

This function does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume.

There’s no equivalent code in unix_prim_file.c, FWIW

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews