SMath Studio Forum
»
SMath Studio
»
Questions
»
CurrentDirectory("") ... gone?
  Rank: Advanced Member Groups: Registered
Joined: 02/04/2018(UTC) Posts: 126  Was thanked: 19 time(s) in 18 post(s)
|
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? Edited by user 21 September 2022 20:23:00(UTC)
| Reason: Not specified
|
|
|
|
  Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,462   Was thanked: 1243 time(s) in 724 post(s)
|
Yes, functions have moved to another plugin - Mathcad Toolbox. You can also use the CWD variable. Edited by user 21 September 2022 21:56:08(UTC)
| Reason: Not specified |
Russia ☭ forever Viacheslav N. Mezentsev |
 1 user thanked uni for this useful post.
|
|
|
  Rank: Advanced Member Groups: Registered
Joined: 02/04/2018(UTC) Posts: 126  Was thanked: 19 time(s) in 18 post(s)
|
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!
|
|
|
|
  Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,462   Was thanked: 1243 time(s) in 724 post(s)
|
Originally Posted by: wb.c  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.  Originally Posted by: wb.c  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. Edited by user 22 September 2022 08:14:23(UTC)
| Reason: Not specified |
Russia ☭ forever Viacheslav N. Mezentsev |
 1 user thanked uni for this useful post.
|
|
|
  Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,894  Was thanked: 1056 time(s) in 676 post(s)
|
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. Edited by user 22 September 2022 11:33:01(UTC)
| Reason: Not specified |
|
 2 users thanked mkraska for this useful post.
|
on 22/09/2022(UTC), on 22/09/2022(UTC)
|
|
  Rank: Advanced Member Groups: Registered
Joined: 02/04/2018(UTC) Posts: 126  Was thanked: 19 time(s) in 18 post(s)
|
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](/forum/resource.ashx?a=45411&b=2) Just my two cents on the matter...
|
|
|
|
  Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,462   Was thanked: 1243 time(s) in 724 post(s)
|
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 |
|
|
|
  Rank: Advanced Member Groups: Registered
Joined: 02/04/2018(UTC) Posts: 126  Was thanked: 19 time(s) in 18 post(s)
|
Seems reasonable to me. Thanks uni.
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
CurrentDirectory("") ... gone?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.