Skip to content

does not seem to be case sensative #98

Open

Description

@zaslove

Hallo,
I am not sure if this is a bug or something that is done on purpose. The file path does not appear to be case sensative. For example, both of these work. The file path on the one is without a capital f for file and for the second one there is a capital F for file.

df1 <- readRDS(here("final_data/xxx.RDS") )

df2 <- readRDS(here("Final_data/xxx.RDS") )

best,
Andrej

Activity

  1. krlmlr commented on Oct 2, 2023

    @krlmlr
    Member

    Thanks. The paths are different, but perhaps your file system is case-insensitive?

  2. zaslove commented on Oct 2, 2023

    @zaslove
    Author

    is there a way to make them case sensitive ...

  3. zaslove commented on Oct 2, 2023

    @zaslove
    Author

    thus the case sensitivity is not something that the here function catches?

  4. krlmlr commented on Oct 2, 2023

    @krlmlr
    Member

    A small example:

    upper <- here::here("DESCRIPTION")
    upper
    #> [1] "/Users/kirill/git/R/fledge/DESCRIPTION"
    lower <- here::here("description")
    lower
    #> [1] "/Users/kirill/git/R/fledge/description"
    
    # Different paths
    identical(upper, lower)
    #> [1] FALSE
    
    # Same canonical path
    identical(fs::path_real(upper), fs::path_real(lower))
    #> [1] TRUE
    fs::path_real(lower)
    #> /Users/kirill/git/R/fledge/DESCRIPTION
    
    # Same file
    identical(readLines(upper), readLines(lower))
    #> [1] TRUE

    Created on 2023-10-02 with reprex v2.0.2

    The paths are different, but they point to the same file. I'm on macOS, the behavior will be the same on Windows, but most likely different on Linux. Are you looking for the functionality that fs::path_real() provides?

  5. zaslove commented on Oct 2, 2023

    @zaslove
    Author

    Hallo,
    Thanks. I was just using the here function to import a data file, as I normally do. I miss typed the file name, with a lower case and I was still able to get the same file. I was surprised that it worked.

    In other words, my file with my data file stays the same but I am able to access it with a upper and lower case using the here function from my script.

    The file with my data is the following: final_data

    I can access the same data file with the two scripts below.

    df1 <- readRDS(here("final_data/xxx.RDS") )

    df2 <- readRDS(here("Final_data/xxx.RDS") )

    I hope this makes sense ...

  6. krlmlr commented on Oct 2, 2023

    @krlmlr
    Member

    I think we're almost on the same page here. What happens if you ask fs::path_real(here("final_data/xxx.RDS")) ?

  7. zaslove commented on Oct 2, 2023

    @zaslove
    Author

    Yes, so if I do that then I get the data. Sorry I changed the file names but the concept works the same. The data file can be upper or lower case and I get the same data file.

    If I do this, then I get the data:

    fs::path_real(here("data/poppa2.rds"))
    C:/Users/zaslo/Main_Documents_Folder/RESEARCH/CURRENT_RESEARCH/poppa_democracy_paper/data/poppa2.RDS

    Here I get the same data. The fs::path_real is upper case but the path file is lower.

    fs::path_real(here("Data/poppa2.rds"))
    C:/Users/zaslo/Main_Documents_Folder/RESEARCH/CURRENT_RESEARCH/poppa_democracy_paper/data/poppa2.RDS

  8. zaslove commented on Oct 2, 2023

    @zaslove
    Author

    so what does this all mean :-)

  9. krlmlr commented on Oct 2, 2023

    @krlmlr
    Member

    Sorry, I don't understand the question.

  10. zaslove commented on Oct 2, 2023

    @zaslove
    Author

    oh sorry. I was just wondering where this leaves the discussion. In the end, the path is not case sensitive but it accesses the same file?

  11. krlmlr commented on Oct 2, 2023

    @krlmlr
    Member
    • The path is a string, strings are case-sensitive. This means "a" != "A"
    • Your file system is case-insensitive. Two different paths can point to the same file
    • You can get a canonical path with fs::path_real(). Two different canonical paths point to different files
  12. zaslove commented on Oct 3, 2023

    @zaslove
    Author

    Many thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions