void commands_ns::DelFile(FileSystem *fs, int argc, char *argv[], std::ostream& out) { if (argc != 1) { out << "Неправильное количество параметров" << std::endl; return; } if (strlen(argv[0]) > 41) { out << "Введены некорректные данные" << std::endl; return; } char *nt[2]; nt[0] = strtok(argv[0], "."); nt[1] = strtok(NULL, ""); char *s = strtok(NULL, ".,-!"); if ( (!nt[0]) || (!nt[1]) || (s) ) { out << "Введены некорректные данные" << std::endl; return; } if (fs->names_types(nt[0])||fs->names_types(nt[1])) { out << "Введены некорректные данные" << std::endl; return; } FileIterator* fi = fs->GetIterator(); FileIterator* prevfi = fs->GetIterator(); int j = 0; int next_index; int n = fs->GetFilesCount(); if (fs->GetFilesCount() != 0) { while (fi->HasNext()) { fi->Next(); FileDescriptor* fd = fi->GetFileDescriptor(); next_index = fi->GetNextIndex(); if (strcmpi(fd->GetName(), nt[0]) == 0 && strcmpi(fd->GetType(), nt[1]) == 0) { if (j == 0) { fs->set_first_file(next_index); } else { prevfi->set_next(next_index); } fi->Delete(); out << "Файл удален." << std::endl; return; } prevfi->Next(); j++; } out << "Файл с указанным именем не существует" << std::endl; } else out << "Файлов в системе не обнаружено." << std::endl; }