swiftperfect

How to get path of root directory of your project folder in Perfect 2.0?


As you know for server side swift Perfect 2.0 framework is out. I was trying to get path for root directory but didn't have any luck yet.

Snippet 1

let fileDir = Dir("/Resources/fileuploads")
print(fileDir.path)

this code give me path as

/Resources/fileuploads

Snippet 2

let fileDir = Dir(Dir.workingDir.path + "Resources/fileuploads")
print(fileDir.path)

this code gives me path as

/Users/username/Library/Developer/Xcode/DerivedData/projname-acxmbygsjkthxvbigpfoqesstidh/Build/Products/Debug/Resources/fileuploads/

However actual path where i want it, to point to is.

/Users/username/Documents/folderOne/folderTwo/projname/Resources/fileuploads/

where

/Users/username/Documents/folderOne/folderTwo/projname

is the path where my root folder of the project is located.

Question

how do i get path to root folder of the project ?


Solution

  • After a long research, i found out that its unnecessary to get this location. the directory returned by Dir will be enough to store my files.