GSoC/GCI Archive
Google Code-in 2011 Parrot Foundation

Fix cross-platform path handling

completed by: Nagato Yuki

mentors: Andrew Whitworth

Task Description

Parrot Ticket #1282 describes a problem with the OS PMC type. The OS PMC implements a variety of routines for interacting with the operating system and file system. The problem is that the path separator slashes ('/' on linux, '\\' on windows) get mixed and matched. We need to fix this.

In src/library.c there is a function cnv_to_win32_filesep to convert to windows slashes when we're on Windows systems. This function is a little messy, poorly named and not used consistently.

Rename the function cnv_to_win32_filesep to Parrot_lib_fix_path_slashes. Make it a public function (not "static"). Fix the function so that it converts to the current platform (Convert '\\' to '/' on linux, convert '/' to '\\' on windows). Right now it only converts to windows-style slashes, you need to fix it to do both. Use your new function in src/dynpmc/os.pmc in the cwd method to fix Ticket # 1282. Make sure the new function is used consistently in src/library.c, wherever it might be needed.

Notice that the STRING* type in Parrot is more complicated than the "char*" from normal C. A Parrot STRING contains information about encodings and charsets, buffer allocation and management, and other details. See the existing code in src/library.c for code examples. If you need additional functionality, look at src/string/api.c for more functions.

Steps To Complete This Task

  1. Create a fork of parrot.git on
  2. Rename your function in src/library.c. Make it not static.
  3. Run "make headerizer" to update header files
  4. Use your new function in src/dynpmc/os.pmc
  5. Scan through src/library.c and make sure your new function is used everywhere it should be used.
  6. Build parrot and run it's test suite (make fulltest) to verify that things still work
  7. Create a Github pull request (button on the upper right of your fork) to have your changes incorporated into the master repository


  1. Proper native path handling is important for consistent, correct behavior on all systems.
  2. Being able to write code once and have it "just work" on all platforms is important. Parrot can handle the messy details of path separators.


  1. C Programming Language

Additional Links