CurrentDirectory("") ... gone?

CurrentDirectory("") ... gone? - Messages

#1 Posted: 9/21/2022 2:18:31 PM
Wesly Centerwall

Wesly Centerwall

26 likes in 156 posts.

Group: User

I've had to pull up some older SMath files that I had saved and it seems like CurrentDirectory("" ) is no longer working.
Did something change?
#2 Posted: 9/21/2022 3:53:17 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Yes, functions have moved to another plugin - Mathcad Toolbox.
You can also use the CWD variable.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Wesly Centerwall 9/21/2022 4:13:00 PM
#3 Posted: 9/21/2022 4:19:23 PM
Wesly Centerwall

Wesly Centerwall

26 likes in 156 posts.

Group: User

Thanks uni!
Follow up question: rfile, wfile, dfile are only working with the default "user" path? No way to use these functions with a different path?

My goal is to be able to delete a file of my choosing in a path of my choosing.

Thanks in advance!
#4 Posted: 9/22/2022 1:57:49 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

Follow up question: rfile, wfile, dfile are only working with the default "user" path? No way to use these functions with a different path?



You can use wfile(3) and rfile(2) from Mathcad Toolbox plugin.

wfile.jpg

Wrote

My goal is to be able to delete a file of my choosing in a path of my choosing.



I can add dfile(2) for this.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
sergio 9/22/2022 7:31:00 AM
#5 Posted: 9/22/2022 5:29:23 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

dfile() applied to arbitrary paths can create arbitrary damage, think of usage where the path might be calculated and the formula is wrong. There should be some protection mechanism like

- mandatory whitelist of folders, where SMath is allowed to perform delete operations, this might include document directory by default
- mandatory whitelist of file types which are allowed to be deleted by SMath
- mandatory popup dialog for confirmation (this probably will annoy if such operations occure frequently)

Strictly seen, this should also apply to wfile() or any other writing functions.
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 users liked this post
sergio 9/22/2022 7:31:00 AM, Вячеслав Мезенцев 9/22/2022 1:03:00 PM
#6 Posted: 9/22/2022 11:21:01 AM
Wesly Centerwall

Wesly Centerwall

26 likes in 156 posts.

Group: User

I think that if you start to idiot proof SMath, it will become as stupid as the users its designed for.
In the end, the path is not arbitrary, and its not like you are deleting entire directories, dfile(x,x) should be made to only delete specified files not folders.
The file would need to be chosen, so not arbitrary as it sounds.

Microsoft Excel for example is a much larger and commonly used program that allows for the same with only a single "enable macros" toggle.
We could do the same, withing the plugin that carries these file manipulation functions, have a toggle that enables these functions.
In this way, a user is not exposed unknowingly to these functions.
Similar to the way we enable document mode.
2022-09-22 10_18_21-SMath Solver 1.0.8253 - [Worksheet1].png
Just my two cents on the matter...
#7 Posted: 9/22/2022 1:18:28 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

I can add 2 variables (wfile and dfile) and use their string value as a file filter allowing you to work only with those files whose name matches the mask or masks. You can use regular expressions.
In this way, you can manually specify the limits of the sandbox that the write and delete functions work with. By default, use the user folder.
Russia ☭ forever, Viacheslav N. Mezentsev
#8 Posted: 9/22/2022 1:59:26 PM
Wesly Centerwall

Wesly Centerwall

26 likes in 156 posts.

Group: User

Seems reasonable to me.
Thanks uni.
  • New Posts New Posts
  • No New Posts No New Posts