Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXISTS does this work for all OS automatically?

0 Kudos

Hi SAP experts,

I would like to ask for an advice on using DIRECTORY EXISTS static method from CL_GUI_FRONTEND_SERVICE class.

I am trying to create a generic file validator that iterates to all directories given the path from user's file system. However, i am concerned with the user's OS, what if the user is using a different OS such as Linux or Solaris? if i am not mistaken, i believe they use slash (/) instead of backslash(\).

Will this be able to get accommodated by DIRECTORY EXISTS?


Thanks and warmest regards,

Ryann

1 ACCEPTED SOLUTION

Juwin
Active Contributor
0 Kudos

Hi Ryann,

You can use CL_GUI_FRONTEND_SERVICES=>GET_FILE_SEPARATOR to get the separator as per the Operating system.

Thanks,

Juwin

5 REPLIES 5

former_member289261
Active Contributor
0 Kudos

Hi,

I am afraid you will have to use slashes as per the OS.

Windows uses '\' while all Linux versions use '/' for directory access.

Juwin
Active Contributor
0 Kudos

Hi Ryann,

You can use CL_GUI_FRONTEND_SERVICES=>GET_FILE_SEPARATOR to get the separator as per the Operating system.

Thanks,

Juwin

0 Kudos

Hi Juwin,

Thanks, this is a possibility. I tried it on a test program and it returns the correct separator under my OS. 

Also inside the code method GET_FILE_SEPARATOR, are the variables: P_SEPARATOR_WINDOWS 'which is initialized value at '\'

P_SEPARATOR_UNIX which is initialized value at '/'

However, there's one thing i want to be sure of, does this act like the SY-OPSYS? where it checks the OS of the application server instead of where the SAP GUI is being run (machine of the user)?

Regards,

Ryann

Juwin
Active Contributor
0 Kudos

Yes, it is supposed to. But I haven't got a chance to try this in a non-windows machine.

Thanks

0 Kudos

This is ok now Juwin. Closing the Thread. Thanks guys!