static char * to_vms_file_spec (char *filespec) { strncpy (vms_filespec, "", MAXPATH); decc$to_vms (filespec, translate_unix, 1, 1); strncpy (vms_filespec, filename_buff, MAXPATH); vms_filespec [MAXPATH - 1] = (char) 0; return vms_filespec; }
static char * to_host_file_spec (char *filespec) { strcpy (new_host_filespec, ""); if (strchr (filespec, ']') || strchr (filespec, ':')) strcpy (new_host_filespec, filespec); else { decc$to_vms (filespec, translate_unix, 1, 1); strcpy (new_host_filespec, filename_buff); } return new_host_filespec; }
static char * to_host_file_spec (char *filespec) { #ifdef VMS if (strchr (filespec, ']') || strchr (filespec, ':')) return filespec; else { strcpy (filename_buff, filespec); decc$to_vms (filespec, translate_unix, 1, 1); strcpy (new_host_filespec, filename_buff); return new_host_filespec; } #else return filespec; #endif }
bool RemoveFile(const string& path) { int iCount; int iStat; // UNIX style filenames with a wildcard aren't removed so if it looks // like a UNIX style path, then convert to an OpenVMS style filename so // all versions will get removed. if (path.find('/') != string::npos) { iCount = decc$to_vms(path.c_str(), ProcessName, 0, 0); iStat = iCount == 0; } else iStat = RemoveVmsFile(path); return iStat == 0; }
static char * to_host_dir_spec (char *dirspec) { int len = strlen (dirspec); strcpy (new_host_dirspec, dirspec); if (strchr (new_host_dirspec, ']') || strchr (new_host_dirspec, ':')) return new_host_dirspec; while (len > 1 && new_host_dirspec [len-1] == '/') { new_host_dirspec [len-1] = 0; len--; } decc$to_vms (new_host_dirspec, translate_unix, 1, 2); strcpy (new_host_dirspec, filename_buff); return new_host_dirspec; }
static int translate_path_posix2vms( string * path ) { int translated = 0; string as_dir[ 1 ]; string as_file[ 1 ]; int dir_count; int file_count; unsigned char is_dir; unsigned char is_file; unsigned char is_ambiguous; string_new( as_dir ); string_new( as_file ); m_vmsfilespec = as_dir; /* MATCH 0:do not allow wildcards, 0:allow directories (2:dir only) */ dir_count = decc$to_vms( path->value, copy_vmsfilespec, 0, 2 ); m_vmsfilespec = as_file; /* MATCH 0:do not allow wildcards, 0:allow directories (2:dir only) */ file_count = decc$to_vms( path->value, copy_vmsfilespec, 0, 0 ); m_vmsfilespec = NULL; translated = ( file_count || dir_count ); if ( file_count && dir_count ) { struct stat statbuf; /* use as_file only when exists AND as_dir does not exist * otherwise use as_dir */ if ( stat(as_dir->value, &statbuf ) < 0 && stat(as_file->value, &statbuf ) > 0 && ( statbuf.st_mode & S_IFREG ) ) { string_truncate( path, 0 ); string_append( path, as_file->value ); } else { string_truncate( path, 0 ); string_append( path, as_dir->value ); } } else if ( file_count ) { string_truncate( path, 0 ); string_append( path, as_file->value ); } else if ( dir_count ) { string_truncate( path, 0 ); string_append( path, as_dir->value ); } else { /* error: unable to translate path to native format */ translated = 0; } string_free( as_dir ); string_free( as_file ); return translated; }