Class: Vertx::FileSystem
- Inherits:
-
Object
- Object
- Vertx::FileSystem
- Defined in:
- src/main/api_shim/core/file_system.rb
Overview
Represents the file-system and contains a broad set of operations for manipulating files.
An asynchronous and a synchronous version of each operation is provided.
The asynchronous versions take a handler as a final argument which is
called when the operation completes or an error occurs. The handler is called
with two arguments; the first an exception, this will be nil if the operation has
succeeded. The second is the result - this will be nil if the operation failed or
there was no result to return.
The synchronous versions return the results, or throw exceptions directly.
Constant Summary
- @@j_fs =
org.vertx.java.platform.impl.JRubyVerticleFactory.vertx.fileSystem()
Class Method Summary (collapse)
-
+ (Object) chmod(path, perms, dir_perms = nil, &block)
Change the permissions on a file, asynchronously.
-
+ (Object) chmod_sync(path, perms, dir_perms = nil)
Synchronous version of #FileSystem#FileSystem.chmod.
-
+ (Object) copy(from, to, &block)
Copy a file, asynchronously.
-
+ (Object) copy_recursive(from, to, &block)
Copy a file recursively, asynchronously.
-
+ (Object) copy_recursive_sync(from, to)
Synchronous version of #FileSystem#FileSystem.copy_recursive.
-
+ (Object) copy_sync(from, to)
Synchronous version of #FileSystem#FileSystem.copy.
-
+ (Object) create_file(path, perms = nil, &block)
Create a new empty file, asynchronously.
-
+ (Object) create_file_sync(path, perms = nil)
Synchronous version of #FileSystem#FileSystem.create_file.
-
+ (Object) delete(path, &block)
Delete a file on the file system, asynchronously.
-
+ (Object) delete_recursive(path, &block)
Delete a file on the file system recursively, asynchronously.
-
+ (Object) delete_recursive_sync(path)
Synchronous version of #FileSystem#FileSystem.delete_recursive.
-
+ (Object) delete_sync(path)
Synchronous version of #FileSystem#FileSystem.delete.
-
+ (Boolean) exists?(path, &block)
Check if a file exists, asynchronously.
-
+ (Boolean) exists_sync?(path)
Synchronous version of #FileSystem#FileSystem.exists?.
-
+ (Object) fs_props(path, &block)
Get properties for the file system, asynchronously.
-
+ (Object) fs_props_sync(path)
Synchronous version of #FileSystem#FileSystem.fs_props.
-
+ (Object) link(link, existing, &block)
Create a hard link, asynchronously..
-
+ (Object) link_sync(link, existing)
Synchronous version of #FileSystem#FileSystem.link.
-
+ (Object) mkdir(path, perms = nil, &block)
Create a directory, asynchronously.
-
+ (Object) mkdir_sync(path, perms = nil)
Synchronous version of #FileSystem#FileSystem.mkdir.
-
+ (Object) mkdir_with_parents(path, perms = nil, &block)
Create a directory, and create all it's parent directories if they do not already exist, asynchronously.
-
+ (Object) mkdir_with_parents_sync(path, perms = nil)
Synchronous version of #FileSystem#FileSystem.mkdir_with_parents.
-
+ (Object) move(from, to, &block)
Move a file, asynchronously.
-
+ (Object) move_sync(from, to)
Synchronous version of #FileSystem#FileSystem.move.
-
+ (Object) open(path, perms = nil, read = true, write = true, create_new = true, flush = false, &block)
Open a file on the file system, asynchronously.
-
+ (Object) open_sync(path, perms = nil, read = true, write = true, create_new = true, flush = false)
Synchronous version of #FileSystem#FileSystem.open.
-
+ (Object) props(path, &block)
Get file properties for a file, asynchronously.
-
+ (Object) props_sync(path)
Synchronous version of #FileSystem#FileSystem.props.
-
+ (Object) read_dir(path, filter = nil, &block)
Read a directory, i.e.
-
+ (Object) read_dir_sync(path, filter = nil)
Synchronous version of #FileSystem#FileSystem.read_dir.
-
+ (Object) read_file_as_buffer(path, &block)
Read the contents of an entire file as a Buffer, asynchronously.
-
+ (Object) read_file_as_buffer_sync(path)
Synchronous version of #FileSystem#FileSystem.read_file_as_buffer.
-
+ (Object) read_symlink(link, &block)
Read a symbolic link, asynchronously.
-
+ (Object) read_symlink_sync(link)
Synchronous version of #FileSystem#FileSystem.read_symlink.
-
+ (Object) symlink(link, existing, &block)
Create a symbolic link, asynchronously.
-
+ (Object) symlink_sync(link, existing)
Synchronous version of #FileSystem#FileSystem.symlink.
-
+ (Object) truncate(path, len, &block)
Truncate a file, asynchronously.
-
+ (Object) truncate_sync(path, len)
Synchronous version of #FileSystem#FileSystem.truncate.
-
+ (Object) unlink(link, &block)
Unlink a hard link.
-
+ (Object) unlinkSync(link)
Synchronous version of #FileSystem#FileSystem.unlink.
-
+ (Object) write_buffer_to_file(path, buffer, &block)
Write a [Buffer] as the entire contents of a file, asynchronously.
-
+ (Object) write_buffer_to_file_sync(path, buffer)
Synchronous version of #FileSystem#FileSystem.write_buffer_to_file.
Class Method Details
+ (Object) chmod(path, perms, dir_perms = nil, &block)
Change the permissions on a file, asynchronously. If the file is directory then all contents will also have their permissions changed recursively.
http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html. This is
used to set the permissions for any regular files (not directories).
227 228 229 230 |
# File 'src/main/api_shim/core/file_system.rb', line 227 def FileSystem.chmod(path, perms, dir_perms = nil, &block) @@j_fs.chmod(path, perms, dir_perms, ARWrappedHandler.new(block)) self end |
+ (Object) chmod_sync(path, perms, dir_perms = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.chmod
233 234 235 236 |
# File 'src/main/api_shim/core/file_system.rb', line 233 def FileSystem.chmod_sync(path, perms, dir_perms = nil) @@j_fs.chmodSync(path, perms, dir_perms) self end |
+ (Object) copy(from, to, &block)
Copy a file, asynchronously. The copy will fail if from does not exist, or if to already exists.
166 167 168 169 |
# File 'src/main/api_shim/core/file_system.rb', line 166 def FileSystem.copy(from, to, &block) @@j_fs.copy(from, to, ARWrappedHandler.new(block)) self end |
+ (Object) copy_recursive(from, to, &block)
Copy a file recursively, asynchronously. The copy will fail if from does not exist, or if to already exists and is not empty.
If the source is a directory all contents of the directory will be copied recursively, i.e. the entire directory
tree is copied.
182 183 184 185 |
# File 'src/main/api_shim/core/file_system.rb', line 182 def FileSystem.copy_recursive(from, to, &block) @@j_fs.copy(from, to, true, ARWrappedHandler.new(block)) self end |
+ (Object) copy_recursive_sync(from, to)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.copy_recursive
188 189 190 191 |
# File 'src/main/api_shim/core/file_system.rb', line 188 def FileSystem.copy_recursive_sync(from, to) @@j_fs.copySync(from, to, true) self end |
+ (Object) copy_sync(from, to)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.copy
172 173 174 175 |
# File 'src/main/api_shim/core/file_system.rb', line 172 def FileSystem.copy_sync(from, to) @@j_fs.copySync(from, to) self end |
+ (Object) create_file(path, perms = nil, &block)
Create a new empty file, asynchronously.
426 427 428 429 |
# File 'src/main/api_shim/core/file_system.rb', line 426 def FileSystem.create_file(path, perms = nil, &block) @@j_fs.createFile(path, perms, ARWrappedHandler.new(block)) self end |
+ (Object) create_file_sync(path, perms = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.create_file
432 433 434 435 |
# File 'src/main/api_shim/core/file_system.rb', line 432 def FileSystem.create_file_sync(path, perms = nil) @@j_fs.createFileSync(path, perms) self end |
+ (Object) delete(path, &block)
Delete a file on the file system, asynchronously.
The delete will fail if the file does not exist, or is a directory and is not empty.
307 308 309 310 |
# File 'src/main/api_shim/core/file_system.rb', line 307 def FileSystem.delete(path, &block) @@j_fs.delete(path, ARWrappedHandler.new(block)) self end |
+ (Object) delete_recursive(path, &block)
Delete a file on the file system recursively, asynchronously.
The delete will fail if the file does not exist. If the file is a directory the entire directory contents
will be deleted recursively.
322 323 324 325 |
# File 'src/main/api_shim/core/file_system.rb', line 322 def FileSystem.delete_recursive(path, &block) @@j_fs.delete(path, true, ARWrappedHandler.new(block)) self end |
+ (Object) delete_recursive_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.delete_recursive
328 329 330 331 |
# File 'src/main/api_shim/core/file_system.rb', line 328 def FileSystem.delete_recursive_sync(path) @@j_fs.deleteSync(path, true) self end |
+ (Object) delete_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.delete
313 314 315 316 |
# File 'src/main/api_shim/core/file_system.rb', line 313 def FileSystem.delete_sync(path) @@j_fs.deleteSync(path) self end |
+ (Boolean) exists?(path, &block)
Check if a file exists, asynchronously.
439 440 441 442 |
# File 'src/main/api_shim/core/file_system.rb', line 439 def FileSystem.exists?(path, &block) @@j_fs.exists(path, ARWrappedHandler.new(block)) self end |
+ (Boolean) exists_sync?(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.exists?
445 446 447 |
# File 'src/main/api_shim/core/file_system.rb', line 445 def FileSystem.exists_sync?(path) @@j_fs.existsSync(path) end |
+ (Object) fs_props(path, &block)
Get properties for the file system, asynchronously.
451 452 453 454 |
# File 'src/main/api_shim/core/file_system.rb', line 451 def FileSystem.fs_props(path, &block) @@j_fs.fsProps(path, ARWrappedHandler.new(block) { |j_props| FSProps.new(j_props)}) self end |
+ (Object) fs_props_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.fs_props
457 458 459 460 |
# File 'src/main/api_shim/core/file_system.rb', line 457 def FileSystem.fs_props_sync(path) j_fsprops = @@j_fs.fsPropsSync(path) FSProps.new(j_fsprops) end |
+ (Object) link(link, existing, &block)
Create a hard link, asynchronously..
254 255 256 257 |
# File 'src/main/api_shim/core/file_system.rb', line 254 def FileSystem.link(link, existing, &block) @@j_fs.link(link, existing, ARWrappedHandler.new(block)) self end |
+ (Object) link_sync(link, existing)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.link
260 261 262 263 |
# File 'src/main/api_shim/core/file_system.rb', line 260 def FileSystem.link_sync(link, existing) @@j_fs.linkSync(link, existing) self end |
+ (Object) mkdir(path, perms = nil, &block)
Create a directory, asynchronously.
The create will fail if the directory already exists, or if it contains parent directories which do not already
exist.
338 339 340 341 |
# File 'src/main/api_shim/core/file_system.rb', line 338 def FileSystem.mkdir(path, perms = nil, &block) @@j_fs.mkdir(path, perms, ARWrappedHandler.new(block)) self end |
+ (Object) mkdir_sync(path, perms = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.mkdir
344 345 346 347 |
# File 'src/main/api_shim/core/file_system.rb', line 344 def FileSystem.mkdir_sync(path, perms = nil) @@j_fs.mkdirSync(path, perms) self end |
+ (Object) mkdir_with_parents(path, perms = nil, &block)
Create a directory, and create all it's parent directories if they do not already exist, asynchronously.
The create will fail if the directory already exists.
353 354 355 356 |
# File 'src/main/api_shim/core/file_system.rb', line 353 def FileSystem.mkdir_with_parents(path, perms = nil, &block) @@j_fs.mkdir(path, perms, true, ARWrappedHandler.new(block)) self end |
+ (Object) mkdir_with_parents_sync(path, perms = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.mkdir_with_parents
359 360 361 362 |
# File 'src/main/api_shim/core/file_system.rb', line 359 def FileSystem.mkdir_with_parents_sync(path, perms = nil) @@j_fs.mkdirSync(path, perms, true) self end |
+ (Object) move(from, to, &block)
Move a file, asynchronously. The move will fail if from does not exist, or if to already exists.
196 197 198 199 |
# File 'src/main/api_shim/core/file_system.rb', line 196 def FileSystem.move(from, to, &block) @@j_fs.move(from, to, ARWrappedHandler.new(block)) self end |
+ (Object) move_sync(from, to)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.move
202 203 204 205 |
# File 'src/main/api_shim/core/file_system.rb', line 202 def FileSystem.move_sync(from, to) @@j_fs.moveSync(from, to) self end |
+ (Object) open(path, perms = nil, read = true, write = true, create_new = true, flush = false, &block)
Open a file on the file system, asynchronously.
412 413 414 415 |
# File 'src/main/api_shim/core/file_system.rb', line 412 def FileSystem.open(path, perms = nil, read = true, write = true, create_new = true, flush = false, &block) @@j_fs.open(path, perms, read, write, create_new, flush, ARWrappedHandler.new(block){ |j_file| AsyncFile.new(j_file)}) self end |
+ (Object) open_sync(path, perms = nil, read = true, write = true, create_new = true, flush = false)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.open
418 419 420 421 |
# File 'src/main/api_shim/core/file_system.rb', line 418 def FileSystem.open_sync(path, perms = nil, read = true, write = true, create_new = true, flush = false) j_af = @@j_fs.open(path, perms, read, write, create_new, flush) AsyncFile.new(j_af) end |
+ (Object) props(path, &block)
Get file properties for a file, asynchronously.
240 241 242 243 |
# File 'src/main/api_shim/core/file_system.rb', line 240 def FileSystem.props(path, &block) @@j_fs.props(path, ARWrappedHandler.new(block) { |j_props| FileProps.new(j_props) }) self end |
+ (Object) props_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.props
246 247 248 249 |
# File 'src/main/api_shim/core/file_system.rb', line 246 def FileSystem.props_sync(path) j_props = @@j_fs.propsSync(path) FileProps.new(j_props) end |
+ (Object) read_dir(path, filter = nil, &block)
Read a directory, i.e. list it's contents, asynchronously.
The read will fail if the directory does not exist.
then only files which match the filter will be returned.
369 370 371 372 |
# File 'src/main/api_shim/core/file_system.rb', line 369 def FileSystem.read_dir(path, filter = nil, &block) @@j_fs.readDir(path, filter, ARWrappedHandler.new(block)) self end |
+ (Object) read_dir_sync(path, filter = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.read_dir
375 376 377 |
# File 'src/main/api_shim/core/file_system.rb', line 375 def FileSystem.read_dir_sync(path, filter = nil) @@j_fs.readDirSync(path, filter) end |
+ (Object) read_file_as_buffer(path, &block)
Read the contents of an entire file as a Buffer, asynchronously.
381 382 383 384 |
# File 'src/main/api_shim/core/file_system.rb', line 381 def FileSystem.read_file_as_buffer(path, &block) @@j_fs.readFile(path, ARWrappedHandler.new(block) { |j_buff| Buffer.new(j_buff)}) self end |
+ (Object) read_file_as_buffer_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.read_file_as_buffer
387 388 389 |
# File 'src/main/api_shim/core/file_system.rb', line 387 def FileSystem.read_file_as_buffer_sync(path) @@j_fs.readFileSync(path) end |
+ (Object) read_symlink(link, &block)
Read a symbolic link, asynchronously. I.e. tells you where the symbolic link points.
294 295 296 297 |
# File 'src/main/api_shim/core/file_system.rb', line 294 def FileSystem.read_symlink(link, &block) @@j_fs.readSymlink(link, ARWrappedHandler.new(block)) self end |
+ (Object) read_symlink_sync(link)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.read_symlink
300 301 302 |
# File 'src/main/api_shim/core/file_system.rb', line 300 def FileSystem.read_symlink_sync(link) @@j_fs.readSymlinkSync(link) end |
+ (Object) symlink(link, existing, &block)
Create a symbolic link, asynchronously.
268 269 270 271 |
# File 'src/main/api_shim/core/file_system.rb', line 268 def FileSystem.symlink(link, existing, &block) @@j_fs.symlink(link, existing, ARWrappedHandler.new(block)) self end |
+ (Object) symlink_sync(link, existing)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.symlink
274 275 276 277 |
# File 'src/main/api_shim/core/file_system.rb', line 274 def FileSystem.symlink_sync(link, existing) @@j_fs.symlinkSync(link, existing) self end |
+ (Object) truncate(path, len, &block)
Truncate a file, asynchronously. The move will fail if path does not exist.
210 211 212 213 |
# File 'src/main/api_shim/core/file_system.rb', line 210 def FileSystem.truncate(path, len, &block) @@j_fs.truncate(path, len, ARWrappedHandler.new(block)) self end |
+ (Object) truncate_sync(path, len)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.truncate
216 217 218 219 |
# File 'src/main/api_shim/core/file_system.rb', line 216 def FileSystem.truncate_sync(path, len) @@j_fs.truncateSync(path, len) self end |
+ (Object) unlink(link, &block)
Unlink a hard link.
281 282 283 284 |
# File 'src/main/api_shim/core/file_system.rb', line 281 def FileSystem.unlink(link, &block) @@j_fs.unlink(link, ARWrappedHandler.new(block)) self end |
+ (Object) unlinkSync(link)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.unlink
287 288 289 290 |
# File 'src/main/api_shim/core/file_system.rb', line 287 def FileSystem.unlinkSync(link) @@j_fs.unlinkSync(link) self end |
+ (Object) write_buffer_to_file(path, buffer, &block)
Write a [Buffer] as the entire contents of a file, asynchronously.
394 395 396 397 |
# File 'src/main/api_shim/core/file_system.rb', line 394 def FileSystem.write_buffer_to_file(path, buffer, &block) @@j_fs.writeFile(path, buffer, ARWrappedHandler.new(block)) self end |
+ (Object) write_buffer_to_file_sync(path, buffer)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.write_buffer_to_file
400 401 402 403 |
# File 'src/main/api_shim/core/file_system.rb', line 400 def FileSystem.write_buffer_to_file_sync(path, buffer) @@j_fs.writeFileSync(path, buffer) self end |