Author Topic: How to obtain the working directory of the current project?  (Read 6521 times)

timur

  • Senior Community Member
  • Posts: 205
  • Hero Points: 3
I'm having trouble finding the answer to this seemingly simple question.  Is there a built-in Slick-C function that returns the working directory of the current project?  For example, my .vpj file is defined like this:

<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project
   Version="10.0"
   VendorName="SlickEdit"
   WorkingDir="/home/b04825/git/u-boot.1">

So I'm looking for a Slick-C function that returns the string "/home/b04825/git/u-boot.1".

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: How to obtain the working directory of the current project?
« Reply #1 on: July 06, 2011, 04:01:28 PM »
I opened the SE Help and did a Search for "project working", and the first match that caught my eye was a command project_cd that switches the current directory to the current project's working directory.  The command is in wkspace.e, and its source code looks like exactly what you want.

timur

  • Senior Community Member
  • Posts: 205
  • Hero Points: 3
Re: How to obtain the working directory of the current project?
« Reply #2 on: July 06, 2011, 04:26:45 PM »
The project_cd command does not work.  Instead of giving me the working directory of my project, it gives me the directory where the .vpj file is located.  I keep all of my .vpj files in the ~/projects/ directory.

hs2

  • Senior Community Member
  • Posts: 2762
  • Hero Points: 292
Re: How to obtain the working directory of the current project?
« Reply #3 on: July 06, 2011, 05:26:34 PM »
Try:
Code: [Select]
  _str cwd=_ProjectGet_WorkingDir (_ProjectHandle (_project_name));Maybe test cwd != """.

Edit: see this maybe helpful macro to cd to the real project dir.

Good luck, HS2
« Last Edit: July 06, 2011, 05:28:49 PM by hs2 »

timur

  • Senior Community Member
  • Posts: 205
  • Hero Points: 3
Re: How to obtain the working directory of the current project?
« Reply #4 on: July 06, 2011, 05:42:18 PM »
Try:
Code: [Select]
  _str cwd=_ProjectGet_WorkingDir (_ProjectHandle (_project_name));Maybe test cwd != """.

Edit: see this maybe helpful macro to cd to the real project dir.

Good luck, HS2


The link you provided works.  Using just _ProjectGet_WorkingDir() does not work.

Thanks!

hs2

  • Senior Community Member
  • Posts: 2762
  • Hero Points: 292
Re: How to obtain the working directory of the current project?
« Reply #5 on: July 06, 2011, 08:08:41 PM »
Hmm - in fact I've just ripped the code line from my (link) macro...
However, it's fine if you can do what you want now :)
HS2

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: How to obtain the working directory of the current project?
« Reply #6 on: July 06, 2011, 08:44:46 PM »
Sorry, I didn't mean to invoke project_cd, I meant to look at its source to find the line that gets the project working directory.

The code reads the value from the "WorkingDir" field in the .VPJ file.  I wonder why the result doesn't match what the code appears to do.

Anyway, glad you got a solution.