int ft_gnl(const int fd, char **line) { static t_file *myfile; t_file *fptr; char buf[BUFF_SIZE + 1]; int res; if (fd < 0 || !(line) || read(fd, buf, 0) < 0) return (-1); fptr = move_to_file(fd, &myfile); while ((res = read(fd, buf, BUFF_SIZE))) { buf[res] = '\0'; fptr->str = ft_strfjoin(&fptr->str, buf); if (ft_strchr(buf, '\n')) break ; } if (res < BUFF_SIZE && !(ft_strlen(fptr->str))) { delete_current_file(&myfile, fptr, line); return (0); } buffer_update(fptr, line); return (1); }
static int fsu_mv(const char *from, const char *to, int flags) { int rv; struct stat file_stat; rv = rump_sys_stat(to, &file_stat); if (rv == -1 || !S_ISDIR(file_stat.st_mode)) return move_to_file(from, to, flags); return move_to_dir(from, to, flags); }
std::ostream &file::write_data() { if(saved_in_file_) { return file_; } else { if(size() > static_cast<long long>(size_limit_)) { move_to_file(); return file_; } else { return file_data_; } } }