移动ffarchive至新路径后打开ff对象报错的问题求助
问题:移动ff文件至新位置后无法访问,报错
file.access(filename, 0) == 0 is not TRUE 场景复现
在Windows系统中将.ff文件迁移到新目录后,尝试打开ff矩阵对象时触发错误:
> open(my_ff_matrix_1) Error in open.ff(all_results_wo_estimates_ff) : file.access(filename, 0) == 0 is not TRUE
已执行操作
- 检查ff存档信息,发现
$rootpath指向旧路径,于是通过rootpath参数指定新路径加载存档:
ff::ffinfo(path_to_ff_files_in_new_location) # $rootpath仍指向旧位置,加载时指定新路径作为rootpath ff::ffload(ff_files_path , rootpath = path_to_new_location , overwrite = TRUE )
- 加载过程无异常,能正常识别ff对象的类型与维度:
> ff::ffload(ff_files_path + , 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
- 但访问ff矩阵内容时依旧报错:
> 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
解决思路
1. 验证文件实际路径与权限
- 确认报错信息中的文件路径是否真实存在,Windows系统注意路径大小写(虽不敏感,但部分场景可能影响)。
- 检查文件权限:右键目标
.ff文件 → 属性 → 安全,确保当前用户拥有读取权限。
2. 手动更新ff对象的文件路径
ff对象内部存储的仍是旧路径,即使文件已迁移,需要手动修正filename属性:
# 查看当前ff对象记录的路径 print(my_ff_matrix_1@filename) # 更新为新路径下的实际文件路径 my_ff_matrix_1@filename <- file.path(path_to_new_location, "ff_file_1.ff") my_ff_matrix_2@filename <- file.path(path_to_new_location, "ff_file_2.ff") # 再次尝试访问 my_ff_matrix_1[1:5, ]
3. 重新构建ff对象(备选方案)
若上述方法无效,可直接从新路径读取文件重新创建ff矩阵:
my_ff_matrix_1 <- ff::ff(filename = file.path(path_to_new_location, "ff_file_1.ff"))
内容的提问来源于stack exchange,提问作者E. Nygaard
相关产品推荐
相关产品推荐

