Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Access to the Hard Drive of a CPU with RGSS?

Hi ^_^,
Well, my Science Fair Project is on accesing the Hard Drive of a CPU with RGSS/RUBY. For example, is it possible to make a script that can open a file from a file? If anyone can help with this, I'd like to know if it's possible as my "Final" Topic is due in 2-3 days. It can be changed up a bit but must stick to it's roots. The scripting language may change if it's not possible with RGSS/Ruby. Well, I hope someone can help ^_^

PS: Hasn't there been a script where you can bring the volume of your CPU up or down? Because that would be something. I'd just like to know if possible and some comments and ideas ^_^ Because the community of rmxp.org is so friendly, thought I'd ask here ^_^ Thanks in advance. Sorry for taking your time...:D

Your friend,
Dylan Kenny
 

Ter13

Member

First of all, a CPU has no hard drive. A CPU is a Central Processing Unit. In other words, I don't know too many computers that have a hard drive hooked up to their processor... Not directly, anyway...

Second, what you should be asking is about File IO. No, RGSS does not support File IO. RUBY supports File IO, thus RGSS, being based in RUBY should theoretically allow you File IO access. And if it doesn't allow you permission, and there is no reason it shouldn't, you can always just plug some basic C++ into a .DLL file and do it that way.

Try this on for size:

http://www.rubycentral.com/book/ref_c_io.html


Last, your vocabulary on this matter is a little... Strange. Acessing a file from a file? Well, first, files don't acess anything. Applications access files. Files and Applications, though both technically files, what is typically called a file is read by an application, whereas an application is any kind of file that executes in a set way and either accesses or modifies other files, or fulfills an automated function rather than supplying data...

What are you making? RMXP: Spreadsheet? O_o Although it might be cool for you to do your taxes via RMXP, might just be a little impractical...

Eh, best of luck to you.
 
Ummm.... I think he means L1 or L2 Cache?

As far as the volume of the CPU, he might mean the throughput in relation to the FSB and CPU?

Unless he means "PC" instead of "CPU."

What about the File class? Could he then access any file via RMXP?

Here's the File help page:

Code:
File
The file access class, normally created by open or File.open.

Open file objects that cannot be referenced will be closed and discarded by the next garbage collection.

SuperclassIO 
Class MethodsFile.mtime(filename) 
Returns the file's last modified time (Time object).

If time retrieval fails, throws an Errno::EXXX exception.

File.basename(filename[, suffix]) 
Returns the final slash-delimited component of filename. If suffix is supplied and is identical to the end of filename, filename is returned without the suffix.

p File.basename("ruby/ruby.c")        # => "ruby.c"
p File.basename("ruby/ruby.c", ".c")  # => "ruby"
p File.basename("ruby/ruby.c", ".*")  # => "ruby"
p File.basename("ruby/ruby.exe", ".*")  # => "ruby"

See also File.dirname and File.extname.

File.delete(filename ... ) 
Deletes a file or files and returns the number of files deleted. If deletion fails, throws an Errno::EXXX exception.

This method is for file deletion and cannot delete directories.

File.dirname(filename) 
Returns all but the final slash-delimited component of filename. Returns "." (the current directory) for a filename that does not include a slash.

p File.dirname("dir/file.ext")    # => "dir"
p File.dirname("file.ext")        # => "."
p File.dirname("foo/bar/")        # => "foo"
p File.dirname("foo//bar")        # => "foo"

See also File.basename and File.extname.

File.expand_path(path[, default_dir]) 
Returns a string containing path's expanded absolute path. If path is relative, sets default_dir as the base directory. If default_dir is nil or missing, uses the current directory. 

p File.expand_path("..")         # => "/home/matz/work"
p File.expand_path("..", "/tmp") # => "/"


File.extname(filename) 
Returns filename's extension (the string after the final dot). Dots in directory names or at the start of filenames are not considered to be denoting extensions. If filename contains no extension, returns an empty string.

p File.extname("foo/foo.txt")     # => ".txt"
p File.extname("foo/foo.tar.gz")  # => ".gz"
p File.extname("foo/bar")         # => ""
p File.extname("foo/.bar")        # => ""
p File.extname("foo.txt/bar")     # => ""
p File.extname(".foo")            # => ""

See also File.basename and File.dirname.

File.open(path[, mode]) 
File.open(path[, mode]) {|file| ... } 
Opens the file specified by path and returns the file object. If file opening fails, throws an Errno::EXXX exception.

The mode argument is identical to the built-in function open.

Blocks can be specified for open(). When called with a block, executes the block with the given file object. The file will be closed automatically after executing the block.

When a block is specified, the return value of this method is the result of the block's evaluation. 
File.rename(from, to) 
Renames file, moving it to a different directory as required. If a file already exists at the destination, it is overwritten.

Returns 0 when file movement is successful; when it fails, throws an Errno::EXXX exception.

Methodsmtime 
Returns the file's last modified time (Time object).

If time retrieval fails, throws an Errno::EXXX exception.

path 
Returns the path of the opened file.
 

Ter13

Member

Based upon his post, I have ascertained that he intended to say PC, rather than CPU. It's quite obvious. "Volume of CPU", I believe he means the output volume of the computer, as for the "Hard drive of a CPU", and opening a "file from a file", I believe he just means File I/O from a script. He just isn't the computer savvy type, I assume, and is using strange vocabulary on the matter.
 

Erk

Member

Wow, that is a really impressive bit of technical confusion.

Dylan, I'm going to go out on a limb and wonder if you held this project off until the last minute? It doesn't seem like you did much background research (read: ANY background research). If you are really making a science project, you will want to get your terminology straight first. Try this as a start point but remember that wikipedia is not the be-all end-all reference; there are often errors. Should be fine for this stuff.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top