Welcome, Guest. Please login or register.

Author Topic: [C] Convert from volume name to device  (Read 4636 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline nyteschaydeTopic starter

  • VIP / Donor - Lifetime Member
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 643
    • Show all replies
    • http://www.nyteshade.com
[C] Convert from volume name to device
« on: February 04, 2018, 05:53:54 AM »
So I am trying to figure out how to get the device name from a volume name in 1.3 (v34) friendly fashion. I know I can get the current directory using something like this:

Code: [Select]


/* Open libs above */
if (ExecBase && DOSBase) {
  struct CommandLineInterface *cli = Cli();
  /* also obtainable from BADDR(((struct Process *)FindTask(NULL))->pr_CLI); */
 

  printf("Current dir: %s\n", BSTRtoSTR(cli->cli_SetName))
}



Where fetching the volume name would involve everything up to the ":" in the current directory string. But I still cannot seem to find a V34 way to translate this into a device name.

Ideally, I'd like a CLI command that reports the device name of the disk it is run from.

Ideas? I'm tired and have been combing through the autodocs and headers and blindly testing stuff with GCC but haven't had much luck with this last hurdle.
Senior MTS Software Engineer with PayPal
Amigas: A1200T 060/603e PPC • A1200T 060 • A4000D 040 • A3000 (x2) • A2000 Vamp/V2 • A1200 (x4) • A1000 (x3) • A600 Vamp/V1 • A500
 

Offline nyteschaydeTopic starter

  • VIP / Donor - Lifetime Member
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 643
    • Show all replies
    • http://www.nyteshade.com
Re: [C] Convert from volume name to device
« Reply #1 on: February 04, 2018, 06:27:45 PM »
Quote from: olsen;835755
Here you go, this should get the job done:


Thanks! I'll play with these today!!
Senior MTS Software Engineer with PayPal
Amigas: A1200T 060/603e PPC • A1200T 060 • A4000D 040 • A3000 (x2) • A2000 Vamp/V2 • A1200 (x4) • A1000 (x3) • A600 Vamp/V1 • A500
 

Offline nyteschaydeTopic starter

  • VIP / Donor - Lifetime Member
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 643
    • Show all replies
    • http://www.nyteshade.com
Re: [C] Convert from volume name to device
« Reply #2 on: February 04, 2018, 06:29:52 PM »
Quote from: olsen;835754
Careful, volume names are not necessarily unique. Your best bet here is to get a lock on the volume you are interested in and use that information to find the device which that specific volume is associated with (device names are unique).

Careful about cli_SetName, too, because the contents of that string may not be sound. The CD command may update it, but the name of the current directory is not reliably tied to the current directory of the shell. For example, if you run a program in the shell, it could by accident or design change the current directory when exiting. The cli_SetName contents will then no longer reflect the state of things.

As for some handy code to help you along, I think I can knock something together which should be useful to you :)  The reason why you drew a blank when checking up the autodocs and headers is likely due to the fact that the relevant information is deeply buried within dos.library, and they do things differently there, if at all. The 1.3 autodocs do not cover the relevant dos.library data structures, and the dos.library header files assume familiarity with the data structure contents rather than provide guidance for becoming familiar with them.


Sheesh, tell me about it! Thanks. I'd love finding more about this stuff. I have Amigas ranging from base A1000s to fully modded A3/4000s and A1200s. I'm making a dev environment to my liking for the A1000 hence the 1.3 related stuff (not saying an A1000 can't run >=2.0)
Senior MTS Software Engineer with PayPal
Amigas: A1200T 060/603e PPC • A1200T 060 • A4000D 040 • A3000 (x2) • A2000 Vamp/V2 • A1200 (x4) • A1000 (x3) • A600 Vamp/V1 • A500
 

Offline nyteschaydeTopic starter

  • VIP / Donor - Lifetime Member
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 643
    • Show all replies
    • http://www.nyteshade.com
Re: [C] Convert from volume name to device
« Reply #3 on: February 05, 2018, 03:21:56 PM »
This is fascinating, but all the traces to what I have seen thus far point to every bit of truth you have spoken about above. I do not need to do a lot in 1.3 and I do not need to go further back than 1.3, though I do have an A500 with 1.2 ROMs, but understanding why things work the way they do is both fun and enlightening. In fact the main reason why I requested volume name to device name conversion was that I could only seem to find docs on getting the volume name. V36 up has so many more calls available for accessing things like this.

I will start a thread about message ports soon too and some of the weirdness I am seeing there. Thanks for such comprehensive answers.
« Last Edit: February 05, 2018, 03:24:25 PM by nyteschayde »
Senior MTS Software Engineer with PayPal
Amigas: A1200T 060/603e PPC • A1200T 060 • A4000D 040 • A3000 (x2) • A2000 Vamp/V2 • A1200 (x4) • A1000 (x3) • A600 Vamp/V1 • A500