- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
为什么我总是收到这个错误?我正在尝试使用 nfs 共享访问文件。我不断收到这些错误。我想通过 nfs 共享访问网络上的一些文件。我引用了一些代码,当我尝试编译这些代码时,出现了这些错误。我是 c++ 的新手。请帮我..!!谢谢。
test@wsm-ela-inc6:~/salu$ make all
g++ -g -Wall -c FS.cpp
FS.cpp: In member function ‘int FS::open(Volume&, const char*, const char*)’:
FS.cpp:128:19: error: no match for ‘operator=’ (operand types are ‘Volume’ and ‘Volume*’)
open_file.volume= &volume;
^
In file included from FS.h:12:0,
from FS.cpp:8:
Volume.h:19:7: note: candidate: Volume& Volume::operator=(const Volume&)
class Volume
^
Volume.h:19:7: note: no known conversion for argument 1 from ‘Volume*’ to ‘const Volume&’
FS.cpp: In member function ‘void FS::close(int)’:
FS.cpp:162:32: error: base operand of ‘->’ has non-pointer type ‘Volume’
Directory dir(open_file.volume->get_fat());
^
FS.cpp: In member function ‘int FS::read(int, char*, int)’:
FS.cpp:196:17: error: no match for ‘operator*’ (operand type is ‘Volume’)
Volume &vol = *open_file.volume;
^
FS.cpp:230:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(read_len<block_size) {
^
FS.cpp: In member function ‘int FS::write(int, char*, int)’:
FS.cpp:267:15: error: no match for ‘operator*’ (operand type is ‘Volume’)
Volume &vol = *open_file.volume;
^
FS.cpp:320:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(read_len<block_size){
^
FS.cpp:275:8: warning: unused variable ‘blk’ [-Wunused-variable]
char blk[MAX_BLOCK_SIZE];
^
FS.cpp: In member function ‘int FS::seek(int, int)’:
FS.cpp:353:35: error: base operand of ‘->’ has non-pointer type ‘Volume’
FAT &fat_file = (open_file.volume->get_fat());
^
FS.cpp: In member function ‘int FS::rmdir(Volume&, const char*, const char*)’:
FS.cpp:462:6: error: ‘file_fcb’ was not declared in this scope
if(file_fcb->type !=DIR_TYPE) return DISK_ERROR;
^
Makefile:13: recipe for target 'FS.o' failed
make: *** [FS.o] Error 1
完整的代码在下面的链接中给出: https://github.com/anieshchawla/networkfilesystem/
/** @file FS.cpp
*
* File System implementation
*
* @author Copyright Robert van Engelen, March 2006
**/
//#include "FCB.h"
#include "FS.h"
#include "Directory.h"
#include <iostream>
FS::FS()
{ }
FS::~FS()
{ }
int FS::open(const Volume& volume, const char *path, const char *name)
{
int fd = 0;
// TODO("Implement FS::open()");
// Check if file was already opened (has entry in open file table):
// Check all open file entries for count > 0.
// If the volume, path, and file name match, then ++count and return fd.
// Otherwise, set fd to a free entry in the open file table with count ==0
// and set the open_file.name to the open() name argument.
// If no entries are available then report error and return DISK_ERROR.
//assert(open_file_table[fd].count == 0);
while((fd < MAX_OPEN_FILES)){
if(strcmp(open_file_table[fd].name.cstr() , name)==0){
break;
}
fd++;
}
if (fd==MAX_OPEN_FILES){
fd = 0;
while(open_file_table[fd].count!=0 && fd<MAX_OPEN_FILES){
fd++;
}
if(fd == MAX_OPEN_FILES) fd=DISK_ERROR;
else {
assert(open_file_table[fd].count == 0);
open_file_table[fd].name = name;
}
}
///////// OpenFile& open_file = open_file_table[fd];
// Create a Directory object for the volume's FAT and use Directory::chdir()
// to move to the path location of the file.
// The dir should now point to the directory of the file.
// If the dir does not exist, then report and return DISK_ERROR.
// Get the FCB of the file via the dir object.
// If there is no FCB, then this is a new file so we create a new FCB with
// size = 0, type = FILE_TYPE, created = time(NULL), and we allocate a new
// start_block from the FAT of the volume.
// Otherwise, if there is an FCB, then set the open_file.size and
// open_file.start_block from the FCB attributes.
// Set the other open_file attributes:
// open_file.pos = 0;
// open_file.current_block = open_file.start_block;
// open_file.current_block_pos = 0;
// open_file.updated = false;
// Increment the open_file.count.
// fd = DISK_ERROR;
OpenFile& open_file = open_file_table[fd];//we used & symbol because if we change open_file we want corresponding
//change to happend in open_file_table entry also
// Create a Directory object for the volume's FAT and use Directory::chdir()
// to move to the path location of the file.
// The dir should now point to the directory of the file.
// If the dir does not exist, then report and return DISK_ERROR.
Directory dir(volume.get_fat());
dir.chdir(path);
//if(!dir.exists(open_file.name)) return DISK_ERROR;
// Get the FCB of the file via the dir object.
const FCB *fcb_file = dir.get_fcb(open_file.name);
// If there is no FCB, then this is a new file so we create a new FCB with
// size = 0, type = FILE_TYPE, created = time(NULL), and we allocate a new
// start_block from the FAT of the volume.
if(fcb_file == NULL) {
FCB fcb;
fcb.size = 0;
fcb.type = FILE_TYPE;
fcb.created = time(NULL);
fcb.start_block = volume.get_fat().alloc();
open_file.start_block = fcb.start_block;
dir.set_fcb(open_file.name, fcb);
}
// Otherwise, if there is an FCB, then set the open_file.size and
// open_file.start_block from the FCB attributes.
else{
open_file.size = fcb_file->size;
open_file.start_block = fcb_file->start_block;
}
// Set the other open_file attributes:
open_file.pos = 0;
open_file.volume= &volume;
open_file.current_block = open_file.start_block;
open_file.current_block_pos = 0;
open_file.updated = false;
// Increment the open_file.count.
open_file.count++;
//fd = DISK_ERROR;
return fd;
/////////////// return fd;
}
void FS::close(int fd)
{
OpenFile& open_file = open_file_table[fd];
assert(open_file.count > 0);
// TODO("Implement FS::close()");
// If the file was updated, update its FCB in the directory:
if (open_file.updated)
{
// Create a Directory object for the volume's FAT and use Directory::chdir()
// to move to the path location of the file.
// The dir should now point to the directory of the file.
// If the dir does not exist, then report and return DISK_ERROR.
Directory dir(open_file.volume->get_fat());
dir.chdir(open_file.path);
if(!dir.exists(open_file.name)) exit DISK_ERROR;
// Get the FCB object of the file, update it with the open_file attributes
// such as size, and set the FCB of the file
const FCB *fcb_file = dir.get_fcb(open_file.name);
if(fcb_file==NULL){
}
open_file.count--;
// What to do if the FCB was not found? This could happen when the file is
// deleted before closed. So rm() must check if the file is not open!
}
// Decrement the open_file.count
}
int FS::read(int fd, char *buf, int len)
{
OpenFile& open_file = open_file_table[fd];
assert(open_file.count > 0);
// TODO("Implement FS::read()");
int block_num = open_file.current_block;
int byte_to_read = len;
Volume &vol = *open_file.volume;
FAT &file_table = vol.get_fat();
Disk &read_fm_disk = file_table.get_disk();
int block_size = read_fm_disk.block_size();
char blk[MAX_BLOCK_SIZE];
// We need to copy data of at most len bytes from disk to the buf argument.
while(len>0){
open_file.current_block = block_num;
size_t read_len = std::min(len,block_size);
read_fm_disk.read(block_num,blk);
int read_length = open_file.current_block_pos + read_len;
//std::cout<<"read length= "<<read_length<<" current_block_pos= "<<open_file.current_block_pos<<std::endl;
//std::cout<<"block_size= "<<read_fm_disk.block_size()<<" block_num "<<block_num<<std::endl;
open_file.pos +=read_len;
if(read_length > block_size ){
memcpy(buf,blk+open_file.current_block_pos,block_size-open_file.current_block_pos);
block_num = file_table.find_next(block_num);
open_file.current_block = block_num;
read_fm_disk.read(block_num,blk);
//std::cout<<"value copied till now is "<< buf<<std::endl;
//std::cout<<"value to be copied "<< blk<<std::endl;
read_len -= (block_size - open_file.current_block_pos);
buf+= (block_size - open_file.current_block_pos);
len-= (block_size - open_file.current_block_pos);
open_file.current_block_pos = 0;
}
//if(block_num==24) std::cout<<"value should be "<<blk+open_file.current_block_pos<<std::endl;
memcpy(buf,blk+open_file.current_block_pos,read_len);
buf+=read_len;
if(read_len<block_size) {
open_file.current_block_pos += read_len;
if(open_file.current_block_pos > block_size) open_file.current_block_pos-=block_size;
}
else{
block_num = file_table.find_next(block_num);
}
len-=read_len;
}
// To do so, use a loop to copy the data in chunks.
// Within the loop, update the open_file.pos position in the file,
// the open_file.current_block, and open_file.current_block_pos offset into
// the current block being read.
// You need to get the FAT of the volume of the open file and use find_next()
// to find the blocks.
// Return the number of bytes copied, or DISK_ERROR when an error occurred.
///////// return DISK_ERROR;
return byte_to_read;
}
int FS::write(int fd, char *buf, int len)
{
OpenFile& open_file = open_file_table[fd];
assert(open_file.count > 0);
open_file.updated = true;
//TODO("Implement FS::write()");
Volume &vol = *open_file.volume;
FAT &file_table = vol.get_fat();
Disk &fm_disk = file_table.get_disk();
Directory dir(file_table);
FCB fcb_of_file;
int block_size = fm_disk.block_size();
char blk[MAX_BLOCK_SIZE];
const FCB *old_fcb_file = dir.get_fcb(open_file.name);
int block_num = open_file.current_block;
// We need to copy data from buf of length len to disk.
// To do so, use a loop to copy the data in chunks.
// Within the loop, update the open_file.size, open_file.pos,
// the open_file.current_block, and open_file.current_block_pos offset into
// the current block being written.
while(len>0){
size_t read_len = std::min(len,block_size);
char buf_disk[block_size];
//std::cout<<"the block number is "<<block_num<<std::endl;
if(open_file.current_block_pos == block_size){
//std::cout<<"we are inside this block num "<<block_num<<std::endl;
block_num = file_table.alloc_next(block_num);
open_file.current_block = block_num;
open_file.current_block_pos = 0;
fm_disk.read(block_num,buf_disk);
}
fm_disk.read(block_num,buf_disk);
char write_buf[block_size];
memcpy(write_buf,buf_disk,open_file.current_block_pos);
int read_length = open_file.current_block_pos+read_len;
open_file.pos +=read_len;
open_file.size+=read_len;
if(read_length > block_size){
memcpy(write_buf+open_file.current_block_pos,buf,block_size- open_file.current_block_pos);
fm_disk.write(block_num,write_buf);
block_num = file_table.alloc_next(block_num);
open_file.current_block = block_num;
buf+=block_size-open_file.current_block_pos;
read_len -= block_size - open_file.current_block_pos;
len-= block_size - open_file.current_block_pos;
open_file.current_block_pos = 0;
fm_disk.read(block_num,buf_disk);
read_length = read_len;
}
memcpy(write_buf+open_file.current_block_pos,buf,read_len);
memcpy(write_buf+read_length, buf_disk + read_length,block_size- read_length);
if(read_len<block_size){
open_file.current_block_pos+=read_len;
if(open_file.current_block_pos>block_size){
open_file.current_block_pos-=block_size;
}
}
fm_disk.write(block_num,write_buf);
buf+=read_len;
len-=read_len;
}
fcb_of_file.type = old_fcb_file->type;
fcb_of_file.size = open_file.size;
fcb_of_file.created = old_fcb_file->created;
fcb_of_file.start_block = old_fcb_file->start_block;
dir.set_fcb(open_file.name,fcb_of_file);
// You need to get the FAT of the volume of the open file and use
// alloc_next() to find or get new blocks.
// Note that writing data inside blocks may require reading blocks first.
// Return DISK_OK or DISK_ERROR.
return DISK_OK;
}
int FS::seek(int fd, int pos)
{
OpenFile& open_file = open_file_table[fd];
assert(open_file.count > 0);
FAT &fat_file = (open_file.volume->get_fat());
int block_size = fat_file.get_disk().block_size();
//TODO("Implement FS::seek()");
//std::cout<<"the file position= "<<open_file.pos<<" requested pos= "<<pos<<std::endl;
int block_shifts = (pos - open_file.pos);
int offset = pos%block_size;
//std::cout<<"block shifts "<<block_shifts<<" offset "<<offset<<std::endl;
if(open_file.size < pos) return DISK_ERROR;
else{
if(block_shifts < 0) {
block_shifts = (int)(pos/block_size) - (int)(open_file.pos/block_size);
if(open_file.pos == ((int)(open_file.pos/block_size))*block_size) block_shifts++;
//std::cout<<"block shifts negative is "<<block_shifts<<std::endl;
block_shifts = open_file.current_block - open_file.start_block + block_shifts;
//std::cout<<"the block shifts from start are "<<block_shifts<<std::endl;
open_file.current_block = open_file.start_block;
}
open_file.pos = pos;
while(block_shifts > 0 ){
open_file.current_block = fat_file.find_next(open_file.current_block);
block_shifts--;
}
open_file.current_block_pos = offset;
return DISK_OK;
}
// Change the open_file.pos, open_file.current_block, and
// open_file.current_block_pos within the allowable range of the file
// where the range is 0 to size-1.
// Return DISK_OK or DISK_ERROR when an error occurred
return DISK_ERROR;
}
int FS::ls(Volume& volume, const char *path)
{
Directory dir(volume.get_fat());
dir.chdir(path);
printf("Volume %s:%s (%d blocks, %d free)\n", volume.get_name(), path, volume.get_fat().num_blocks(), volume.get_fat().num_free_blocks());
dir.list();
return DISK_OK;
}
int FS::rm(Volume& volume, const char *path, const char *name)
{
//TODO("Implement FS::rm()");
int fd = -1;
Directory dir(volume.get_fat());
dir.chdir(path);
FileName file_name(name);
const FCB* file_fcb = dir.get_fcb(file_name);
// Check if this is a regular file.
if(file_fcb->type !=FILE_TYPE) return DISK_ERROR;
// Check if the file is not open.
while((fd < MAX_OPEN_FILES)){
if(strcmp(open_file_table[fd].name.cstr() , name)==0){
break;
}
fd++;
}
// Create a Directory object for the volume's FAT and use Directory::chdir()
// to move to the path location of the file.
// The dir should now point to the directory of the file.
// If the dir does not exist, then report and return DISK_ERROR.
// Use Directory::erase() to remove the file.
if(fd != MAX_OPEN_FILES){
assert(open_file_table[fd].count ==0);
dir.erase(file_name);
return DISK_OK;
}
// Return DISK_OK or DISK_ERROR.
return DISK_ERROR;
}
int FS::mkdir(Volume& volume, const char *path, const char *name)
{
Directory dir(volume.get_fat());
dir.chdir(path);
FileName dir_name(name);
return dir.mkdir(dir_name);
}
int FS::rmdir(Volume& volume, const char *path, const char *name)
{
Directory dir(volume.get_fat());
dir.chdir(path);
FileName dir_name(name);
const FCB* file_fcb = dir.get_fcb(dir_name);
//TODO("Complete FS::rmdir()");
// Check if this is a directory.
if(file_fcb->type !=DIR_TYPE) return DISK_ERROR;
if(!dir.exists(dir_name)) return DISK_ERROR;
// Check if the directory is empty.
//if(!dir.empty()) return DISK_ERROR;
dir.erase(dir_name);
return DISK_OK;
}
/** @file Volume.h
*
* Volume structure
*
* @author Copyright Robert van Engelen, March 2006
**/
#ifndef VOLUME_H
#define VOLUME_H
#include "includes.h"
#include "Disk.h"
#include "FAT.h"
/** A Volume object associates a volume name with a formatted Disk.
*
* The Volume object contains a FAT and a reference to the Disk object.
**/
class Volume
{
private:
/// The volume name.
const char *name;
/// The FAT with the Disk reference.
FAT fat;
public:
/// Create a new named Volume (and FAT) for a formatted Disk object.
Volume(const char *name, Disk& disk);
~Volume();
/// Return the name of this volume.
const char *get_name() const;
/// Return a reference to the FAT of the Disk for this volume.
FAT& get_fat();
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
/*
Volume(const char *name, Disk& disk) : name(strdup(name)), fat(disk)
{ }
~Volume()
{
if (name)
free((void*)name);
}
const char * get_name() const
{
return name;
}
FAT& get_fat()
{
return fat;
}
*/
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
};
#endif
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!