Skip to content

Commit 027ca19

Browse files
committed
fix the issue of check_file_writable for some Linux systems
https://github.com/OpenGene/fastp/issues/50wq
1 parent 14b0fce commit 027ca19

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/options.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ bool Options::validate() {
5050
}
5151

5252
if(!out1.empty()) {
53-
//check_file_writable(out1);
53+
check_file_writable(out1);
5454
if(out1 == out2) {
5555
error_exit("read1 output (--out1) and read1 output (--out2) should be different");
5656
}
5757
}
5858
if(!out2.empty()) {
59-
//check_file_writable(out2);
59+
check_file_writable(out2);
6060
}
6161

6262
if(compression < 1 || compression > 9)
@@ -179,4 +179,4 @@ bool Options::validate() {
179179
error_exit("overrepresentation_sampling should be 1~10000");
180180

181181
return true;
182-
}
182+
}

src/util.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ inline void check_file_valid(const string& s) {
186186
}
187187

188188
inline void check_file_writable(const string& s) {
189-
if(is_directory(s)){
190-
cerr << "ERROR: '" << s << "' is a folder, not a file, quit now" << endl;
189+
string dir = dirname(s);
190+
if(!file_exists(dir)) {
191+
cerr << "ERROR: '" << dir << " doesn't exist. Create this folder and run this command again." << endl;
191192
exit(-1);
192193
}
193-
string dir = dirname(s);
194-
if(!is_directory(dir)){
195-
cerr << "ERROR: '" << s << "' cannot be created, please confirm the folder "<< dir << " exists. Create this folder and run this command again." << endl;
194+
if(is_directory(s)){
195+
cerr << "ERROR: '" << s << "' is not a writable file, quit now" << endl;
196196
exit(-1);
197197
}
198198
}

0 commit comments

Comments
 (0)