Class: Vertx::FileSystem
- Inherits:
-
Object
- Object
- Vertx::FileSystem
- Defined in:
- src/main/ruby_scripts/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.deploy.impl.VertxLocator.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_sym_link(link, &block)
Read a symbolic link, asynchronously.
-
+ (Object) read_sym_link_sync(link)
Synchronous version of #FileSystem#FileSystem.read_sym_link.
-
+ (Object) sym_link(link, existing, &block)
Create a symbolic link, asynchronously.
-
+ (Object) sym_link_sync(link, existing)
Synchronous version of #FileSystem#FileSystem.sym_link.
-
+ (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).
263 264 265 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 263 def FileSystem.chmod(path, perms, dir_perms = nil, &block) @@j_fs.chmod(path, perms, dir_perms, FSWrappedHandler.new(block)) end |
+ (Object) chmod_sync(path, perms, dir_perms = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.chmod
268 269 270 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 268 def FileSystem.chmod_sync(path, perms, dir_perms = nil) @@j_fs.chmodSync(path, perms, dir_perms) end |
+ (Object) copy(from, to, &block)
Copy a file, asynchronously. The copy will fail if from does not exist, or if to already exists.
210 211 212 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 210 def FileSystem.copy(from, to, &block) @@j_fs.copy(from, to, FSWrappedHandler.new(block)) 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.
224 225 226 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 224 def FileSystem.copy_recursive(from, to, &block) @@j_fs.copy(from, to, true, FSWrappedHandler.new(block)) end |
+ (Object) copy_recursive_sync(from, to)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.copy_recursive
229 230 231 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 229 def FileSystem.copy_recursive_sync(from, to) @@j_fs.copySync(from, to, true) end |
+ (Object) copy_sync(from, to)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.copy
215 216 217 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 215 def FileSystem.copy_sync(from, to) @@j_fs.copySync(from, to) end |
+ (Object) create_file(path, perms = nil, &block)
Create a new empty file, asynchronously.
439 440 441 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 439 def FileSystem.create_file(path, perms = nil, &block) @@j_fs.createFile(path, perms, FSWrappedHandler.new(block)) end |
+ (Object) create_file_sync(path, perms = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.create_file
444 445 446 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 444 def FileSystem.create_file_sync(path, perms = nil) @@j_fs.createFileSync(path, perms) 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.
333 334 335 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 333 def FileSystem.delete(path, &block) @@j_fs.delete(path, FSWrappedHandler.new(block)) 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.
346 347 348 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 346 def FileSystem.delete_recursive(path, &block) @@j_fs.delete(path, true, FSWrappedHandler.new(block)) end |
+ (Object) delete_recursive_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.delete_recursive
351 352 353 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 351 def FileSystem.delete_recursive_sync(path) @@j_fs.deleteSync(path, true) end |
+ (Object) delete_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.delete
338 339 340 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 338 def FileSystem.delete_sync(path) @@j_fs.deleteSync(path) end |
+ (Boolean) exists?(path, &block)
Check if a file exists, asynchronously.
450 451 452 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 450 def FileSystem.exists?(path, &block) @@j_fs.exists(path, FSWrappedHandler.new(block)) end |
+ (Boolean) exists_sync?(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.exists?
455 456 457 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 455 def FileSystem.exists_sync?(path) @@j_fs.existsSync(path) end |
+ (Object) fs_props(path, &block)
Get properties for the file system, asynchronously.
461 462 463 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 461 def FileSystem.fs_props(path, &block) @@j_fs.fsProps(path, FSWrappedHandler.new(block) { |j_props| FSProps.new(j_props)}) end |
+ (Object) fs_props_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.fs_props
466 467 468 469 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 466 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..
287 288 289 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 287 def FileSystem.link(link, existing, &block) @@j_fs.link(link, existing, FSWrappedHandler.new(block)) end |
+ (Object) link_sync(link, existing)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.link
292 293 294 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 292 def FileSystem.link_sync(link, existing) @@j_fs.linkSync(link, existing) 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.
360 361 362 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 360 def FileSystem.mkdir(path, perms = nil, &block) @@j_fs.mkdir(path, perms, FSWrappedHandler.new(block)) end |
+ (Object) mkdir_sync(path, perms = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.mkdir
365 366 367 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 365 def FileSystem.mkdir_sync(path, perms = nil) @@j_fs.mkdirSync(path, perms) 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.
373 374 375 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 373 def FileSystem.mkdir_with_parents(path, perms = nil, &block) @@j_fs.mkdir(path, perms, true, FSWrappedHandler.new(block)) end |
+ (Object) mkdir_with_parents_sync(path, perms = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.mkdir_with_parents
378 379 380 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 378 def FileSystem.mkdir_with_parents_sync(path, perms = nil) @@j_fs.mkdirSync(path, perms, true) end |
+ (Object) move(from, to, &block)
Move a file, asynchronously. The move will fail if from does not exist, or if to already exists.
236 237 238 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 236 def FileSystem.move(from, to, &block) @@j_fs.move(from, to, FSWrappedHandler.new(block)) end |
+ (Object) move_sync(from, to)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.move
241 242 243 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 241 def FileSystem.move_sync(from, to) @@j_fs.moveSync(from, to) end |
+ (Object) open(path, perms = nil, read = true, write = true, create_new = true, flush = false, &block)
Open a file on the file system, asynchronously.
426 427 428 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 426 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, FSWrappedHandler.new(block){ |j_file| AsyncFile.new(j_file)}) end |
+ (Object) open_sync(path, perms = nil, read = true, write = true, create_new = true, flush = false)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.open
431 432 433 434 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 431 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.
274 275 276 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 274 def FileSystem.props(path, &block) @@j_fs.props(path, FSWrappedHandler.new(block) { |j_props| FileProps.new(j_props) }) end |
+ (Object) props_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.props
279 280 281 282 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 279 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.
387 388 389 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 387 def FileSystem.read_dir(path, filter = nil, &block) @@j_fs.readDir(path, filter, FSWrappedHandler.new(block)) end |
+ (Object) read_dir_sync(path, filter = nil)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.read_dir
392 393 394 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 392 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.
398 399 400 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 398 def FileSystem.read_file_as_buffer(path, &block) @@j_fs.readFile(path, FSWrappedHandler.new(block) { |j_buff| Buffer.new(j_buff)}) end |
+ (Object) read_file_as_buffer_sync(path)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.read_file_as_buffer
403 404 405 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 403 def FileSystem.read_file_as_buffer_sync(path) @@j_fs.readFileSync(path) end |
+ (Object) read_sym_link(link, &block)
Read a symbolic link, asynchronously. I.e. tells you where the symbolic link points.
321 322 323 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 321 def FileSystem.read_sym_link(link, &block) @@j_fs.readSymLink(link, FSWrappedHandler.new(block)) end |
+ (Object) read_sym_link_sync(link)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.read_sym_link
326 327 328 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 326 def FileSystem.read_sym_link_sync(link) @@j_fs.readSymLinkSync(link) end |
+ (Object) sym_link(link, existing, &block)
Create a symbolic link, asynchronously.
299 300 301 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 299 def FileSystem.sym_link(link, existing, &block) @@j_fs.symLink(link, existing, FSWrappedHandler.new(block)) end |
+ (Object) sym_link_sync(link, existing)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.sym_link
304 305 306 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 304 def FileSystem.sym_link_sync(link, existing) @@j_fs.symLinkSync(link, existing) end |
+ (Object) truncate(path, len, &block)
Truncate a file, asynchronously. The move will fail if path does not exist.
248 249 250 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 248 def FileSystem.truncate(path, len, &block) @@j_fs.truncate(path, len, FSWrappedHandler.new(block)) end |
+ (Object) truncate_sync(path, len)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.truncate
253 254 255 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 253 def FileSystem.truncate_sync(path, len) @@j_fs.truncateSync(path, len) end |
+ (Object) unlink(link, &block)
Unlink a hard link.
310 311 312 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 310 def FileSystem.unlink(link, &block) @@j_fs.unlink(link, FSWrappedHandler.new(block)) end |
+ (Object) unlinkSync(link)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.unlink
315 316 317 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 315 def FileSystem.unlinkSync(link) @@j_fs.unlinkSync(link) end |
+ (Object) write_buffer_to_file(path, buffer, &block)
Write a [Buffer] as the entire contents of a file, asynchronously.
410 411 412 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 410 def FileSystem.write_buffer_to_file(path, buffer, &block) @@j_fs.writeFile(path, buffer, FSWrappedHandler.new(block)) end |
+ (Object) write_buffer_to_file_sync(path, buffer)
Synchronous version of Vertx::FileSystem#FileSystem#FileSystem.write_buffer_to_file
415 416 417 |
# File 'src/main/ruby_scripts/core/file_system.rb', line 415 def FileSystem.write_buffer_to_file_sync(path, buffer) @@j_fs.writeFileSync(path, buffer) end |