Scripting - Chapter 6: The Filesystem

From PlayOnLinux
Revision as of 03:05, 27 February 2015 by RoninDusette (talk | contribs) (Page créée avec « There are a couple of good ways to manipulate your files and directories in Bash. We'll give you the most important commands for writing PlayOnLinux scripts. == PlayOnLi... »)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

There are a couple of good ways to manipulate your files and directories in Bash. We'll give you the most important commands for writing PlayOnLinux scripts.


PlayOnLinux temporary directories

You can use a temporary directory for your script when it runs. To do that:

Syntax:

POL_System_TmpCreate "NameOfTemporaryDirectory"

Example:

POL_System_TmpCreate "MozillaFirefox"

It will create a variable $POL_System_TmpDir that will contain the path of the temporary directory. In this directory, you'll be free to store and modify all the files you want, for the whole script duration.

Delete the temporary directory

Syntax:

POL_System_TmpDelete

Example:

POL_System_TmpDelete

NOTE: that it's useless to remove the files you created in the temporary directory before calling the POL_System_TmpDelete command.

Other filesystem commands

Switching directory

Syntax:

cd "path"

Example:

cd "/path/to/a/directory"
cd "$HOME" # Switch to user's personal directory
cd "$CDROM" # Switch to CD/DVD directory
cd "$POL_System_TmpDir" # Switch to temporary directory

Removing a file or directory

WARNING: this command is very dangerous. It could destroy all your files if you don't handle it properly. For example, if you decide to remove /home/user/.PlayOnLinux/tmp/ and that you inadvertently insert a blank between /home/user/ and .PlayOnLinux, you can say farewell to your documents. PlayOnLinux could not be held responsible for any mishandling on your part.