Class: RStyx::Server::SFileClient

Inherits:
Object
  • Object
show all
Defined in:
lib/rstyx/server.rb

Overview

Server’s representation of the client of an SFile, created when a client opens a file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, fid, mode) ⇒ SFileClient

Create a new SFileClient.

session

The session object associated with the client.

fid

The client’s handle to the file. Note that clients may

use many fids opened representing the same file.
mode

The mode field as received from the client’s Topen

message (including the OTRUNC and ORCLOSE bits)


1136
1137
1138
1139
1140
1141
1142
1143
1144
# File 'lib/rstyx/server.rb', line 1136

def initialize(session, fid, mode)
  @session = session
  @fid = fid
  @truncate = ((mode & OTRUNC) == OTRUNC)
  @orclose = ((mode & ORCLOSE) == ORCLOSE)
  @mode = mode & 0x03     # mask off all but the last two bits
  @offset = 0
  @next_file_to_read = 0
end

Instance Attribute Details

#fidObject (readonly)

The fid which the client used to open the file in question



1114
1115
1116
# File 'lib/rstyx/server.rb', line 1114

def fid
  @fid
end

#modeObject (readonly)

The mode under which the client opened the file in question



1117
1118
1119
# File 'lib/rstyx/server.rb', line 1117

def mode
  @mode
end

#next_file_to_readObject

Used when reading a directory: stores the index of the next child of an SFile to include in an RreadMessage.



1125
1126
1127
# File 'lib/rstyx/server.rb', line 1125

def next_file_to_read
  @next_file_to_read
end

#offsetObject

When a client reads from or writes to file, this records the new offset



1121
1122
1123
# File 'lib/rstyx/server.rb', line 1121

def offset
  @offset
end

#sessionObject (readonly)

The session for which this SFileClient was created



1111
1112
1113
# File 'lib/rstyx/server.rb', line 1111

def session
  @session
end

Instance Method Details

#orclose?Boolean Also known as: delete_on_clunk?

Returns true if the Styx file was opened by the client in the ORCLOSE mode (i.e. the client wants the file deleted on clunk).

Returns:

  • (Boolean)


1158
1159
1160
# File 'lib/rstyx/server.rb', line 1158

def orclose?
  return(@orclose)
end

#readable?Boolean

Check to see if the client can read the file (i.e. the client opened it with read access mode).

Returns:

  • (Boolean)


1168
1169
1170
# File 'lib/rstyx/server.rb', line 1168

def readable?
  return(@mode == OREAD || @mode == ORDWR)
end

#truncate?Boolean

Returns true if the Styx file was opened by the client in the OTRUNC mode.

Returns:

  • (Boolean)


1150
1151
1152
# File 'lib/rstyx/server.rb', line 1150

def truncate?
  return(@truncate)
end

#writable?Boolean

Check to see if the client can write to the file (i.e. the client opened it with write access).

Returns:

  • (Boolean)


1176
1177
1178
# File 'lib/rstyx/server.rb', line 1176

def writable?
  return(@mode == OWRITE || @mode == ORDWR)
end