rwindowsff

Error when trying to open ff object after moving ffarchive to a different location


I just got the following error on a Windows computer when trying to open an .ff file after moving it to another location:

> open(my_ff_matrix_1)
Error in open.ff(all_results_wo_estimates_ff) : 
  file.access(filename, 0) == 0 is not TRUE

This is how I loaded the ffarchive:

ff::ffinfo( path_to_ff_files_in_new_location )
# $rootpath is no longer correct as it points to the old location of the ffarchive, so
# I will provide the path to the new location as the rootpath argument in ffload.

# Load ffarchive using the new location as rootpath
ff::ffload( ff_files_path
            # Where the files from the ffarchive should be extracted to:
            , rootpath = path_to_new_location
            , overwrite = TRUE
)

Loading the ffarchive with ffload() went as expected:

> ff::ffload( ff_files_path
+             # Where the files from the ffarchive should be extracted to:
+             , rootpath = path_to_new_location 
+             , overwrite = TRUE
+ )
[1] "ff_file_1.ff"            
[2] "ff_file_2.ff"
> class(my_ff_matrix_1)
[1] "ff_matrix" "ff_array"  "ff"     
> class(my_ff_matrix_2)
[1] "ff_matrix" "ff_array"  "ff"     
> dim(my_ff_matrix_1)
[1] 1220406       5

However, trying to access the contents of the ff_matrices resulted in the aforementioned error message:

> my_ff_matrix_1[1:5, ]
opening ff C:/Path/to/the/file/which/was/placed/in/the/specified/rootpath/ff_file_1.ff
Error in open.ff(x, assert = TRUE) : 
  file.access(filename, 0) == 0 is not TRUE

Solution

  • It turns out that the issue was that the new file paths exceed Windows' maximum path length (256 characters):

    > physical(my_ff_matrix_1)$filename %>% nchar()
    [1] 262
    

    Moving the ffarchive to a location such that physical(my_ff_matrix_1)$filename %>% nchar() was less than 256 solved the issue.