imap/src/osdep/nt/env_nt.c
/* Build lock directory, check to see if it exists
 * Accepts: return buffer for lock directory
 *	    first part of possible name
 *	    optional second part
 * Returns: pointer to end of buffer if buffer has a good name, else NIL
 */
Build lock directory, check to see if it exists
Accepts: return buffer for lock directory
first part of possible name
optional second part
Returns: pointer to end of buffer if buffer has a good name, else NIL
Build lock directory check to see if it exists Accepts : return buffer for lock directory first part of possible name optional second part Returns : pointer to end of buffer if buffer has a good name else NIL
char *lockdir (char *lock,char *first,char *last)
{
  struct stat sbuf;
  char c,*s;
  if (first && *first) {	
    for (s = lock; c = *first++; *s++ = (c == '/') ? '\\' : c);
    if (last && *last) {	
      if (s[-1] != '\\') *s++ = '\\';
      while (c = *last++) *s++ = (c == '/') ? '\\' : c;
    }
    if (s[-1] == '\\') --s;	
    *s = s[1] = '\0';		
    if (!stat (lock,&sbuf)) {	
      *s++ = '\\';		
      return s;			
    }
  }
  return NIL;			
}
char * lockdir ( char * lock , char * first , char * last ) { struct stat sbuf ; char c , * s ; if ( first && * first ) { for ( s = lock ; c = * first ++ ; * s ++ = ( c == ' ' ) ? ' \\ ' : c ) ; if ( last && * last ) { if ( s [ -1 ] != ' \\ ' ) * s ++ = ' \\ ' ; while ( c = * last ++ ) * s ++ = ( c == ' ' ) ? ' \\ ' : c ; } if ( s [ -1 ] == ' \\ ' ) -- s ; * s = s [ 1 ] = ' \0 ' ; if ( ! stat ( lock , & sbuf ) ) { * s ++ = ' \\ ' ; return s ; } } return NIL ; }
Build lock directory, check to see if it exists
 Accepts: return buffer for lock directory
          first part of possible name
          optional second part
 Returns: pointer to end of buffer if buffer has a good name, else NIL
Build lock directory check to see if it exists Accepts : return buffer for lock directory first part of possible name optional second part Returns : pointer to end of buffer if buffer has a good name else NIL
/* first part must be non-NIL */ /* copy first part */ /* copy last part if specified */ /* write trailing \ in case not in first */ /* delete trailing \ if any */ /* tie off name at this point */ /* does the name exist? */ /* yes, reinstall trailing \ */ /* return the name */ /* failed */