⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cygpath.cc

📁 cygwin, 著名的在win32下模拟unix操作系统的东东
💻 CC
📖 第 1 页 / 共 2 页
字号:
    default:      usage (stderr, 1);    }  if (!windows_flag)    {      cygwin_conv_to_posix_path (buf, buf2);      buf = buf2;    }  else    {      if (shortname_flag)	buf = get_short_name (buf);      if (mixed_flag)	buf = get_mixed_name (buf);    }  printf ("%s\n", buf);  exit (0);}static voiddoit (char *filename){  char *buf;  DWORD len;  int retval;  int (*conv_func) (const char *, char *);  if (!path_flag)    {      len = strlen (filename);      if (len)	len += 100;      else if (ignore_flag)	exit (0);      else	{	  fprintf (stderr, "%s: can't convert empty path\n", prog_name);	  exit (1);	}    }  else if (unix_flag)    len = cygwin_win32_to_posix_path_list_buf_size (filename);  else    len = cygwin_posix_to_win32_path_list_buf_size (filename);  buf = (char *) malloc (len);  if (buf == NULL)    {      fprintf (stderr, "%s: out of memory\n", prog_name);      exit (1);    }  if (path_flag)    {      if (unix_flag)	cygwin_win32_to_posix_path_list (filename, buf);      else	{	  cygwin_posix_to_win32_path_list (filename, buf);	  if (shortname_flag)	    buf = get_short_paths (buf);	  if (longname_flag)	    buf = get_long_paths (buf);	  if (mixed_flag)	    buf = get_mixed_name (buf);	}    }  else    {      if (unix_flag)	conv_func = (absolute_flag ? cygwin_conv_to_full_posix_path :		     cygwin_conv_to_posix_path);      else	conv_func = (absolute_flag ? cygwin_conv_to_full_win32_path :		     cygwin_conv_to_win32_path);      retval = conv_func (filename, buf);      if (mixed_flag)	buf = get_mixed_name (buf);      if (retval < 0)	{	  fprintf (stderr, "%s: error converting \"%s\"\n",		   prog_name, filename);	  exit (1);	}      if (!unix_flag)	{	if (shortname_flag)	  buf = get_short_name (buf);	if (longname_flag)	  buf = get_long_name (buf, len);	}    }  puts (buf);}static voidprint_version (){  const char *v = strchr (version, ':');  int len;  if (!v)    {      v = "?";      len = 1;    }  else    {      v += 2;      len = strchr (v, ' ') - v;    }  printf ("\cygpath (cygwin) %.*s\n\Path Conversion Utility\n\Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\Compiled on %s\n\", len, v, __DATE__);}intmain (int argc, char **argv){  int c, o = 0;  int options_from_file_flag;  char *filename;  prog_name = strrchr (argv[0], '/');  if (prog_name == NULL)    prog_name = strrchr (argv[0], '\\');  if (prog_name == NULL)    prog_name = argv[0];  else    prog_name++;  path_flag = 0;  unix_flag = 1;  windows_flag = 0;  shortname_flag = 0;  longname_flag = 0;  mixed_flag = 0;  ignore_flag = 0;  options_from_file_flag = 0;  allusers_flag = 0;  output_flag = 0;  while ((c = getopt_long (argc, argv, options,			   long_options, (int *) NULL)) != EOF)    {      switch (c)	{	case 'a':	  absolute_flag = 1;	  break;	case 'c':	  CloseHandle ((HANDLE) strtoul (optarg, NULL, 16));	  break;	case 'd':	  if (windows_flag)	    usage (stderr, 1);	  unix_flag = 0;	  windows_flag = 1;	  shortname_flag = 1;	  break;	case 'f':	  file_arg = optarg;	  break;	case 'o':	  options_from_file_flag = 1;	  break;	case 'p':	  path_flag = 1;	  break;	case 'u':	  if (windows_flag || mixed_flag)	    usage (stderr, 1);	  unix_flag = 1;	  break;	case 'w':	  if (windows_flag || mixed_flag)	    usage (stderr, 1);	  unix_flag = 0;	  windows_flag = 1;	  break;	 case 'm':	  unix_flag = 0;	  windows_flag = 1;	  mixed_flag = 1;	  break;	case 'l':	  longname_flag = 1;	  break;	case 's':	  shortname_flag = 1;	  break;	 case 't':	  if (optarg == NULL)	    usage (stderr, 1);	  format_type_arg = (*optarg == '=') ? (optarg + 1) : (optarg);	  if (strcasecmp (format_type_arg, "dos") == 0)	    {	    if (windows_flag || longname_flag)	      usage (stderr, 1);	    unix_flag = 0;	    windows_flag = 1;	    shortname_flag = 1;	    }	  else if (strcasecmp (format_type_arg, "mixed") == 0)	    {	    unix_flag = 0;	    mixed_flag = 1;	    }	  else if (strcasecmp (format_type_arg, "unix") == 0)	    {	    if (windows_flag)	      usage (stderr, 1);	    unix_flag = 1;	    }	  else if (strcasecmp (format_type_arg, "windows") == 0)	    {	    if (mixed_flag)	      usage (stderr, 1);	    unix_flag = 0;	    windows_flag = 1;	    }	  else	    usage (stderr, 1);	  break;	case 'A':	  allusers_flag = 1;	  break;	case 'D':	case 'H':	case 'P':	case 'S':	case 'W':	  if (output_flag)	    usage (stderr, 1);	  output_flag = 1;	  o = c;	  break;	case 'i':	  ignore_flag = 1;	  break;	case 'h':	  usage (stdout, 0);	  break;	case 'v':	  print_version ();	  exit (0);	default:	  usage (stderr, 1);	  break;	}    }  if (options_from_file_flag && !file_arg)    usage (stderr, 1);  if (longname_flag && !windows_flag)    usage (stderr, 1);  if (shortname_flag && !windows_flag)    usage (stderr, 1);  if (!unix_flag && !windows_flag && !mixed_flag && !options_from_file_flag)    usage (stderr, 1);  if (!file_arg)    {      if (output_flag)	dowin (o);      if (optind != argc - 1)	usage (stderr, 1);      filename = argv[optind];      doit (filename);    }  else    {      FILE *fp;      char buf[PATH_MAX * 2 + 1];      if (argv[optind])	usage (stderr, 1);      if (strcmp (file_arg, "-") != 0)	fp = fopen (file_arg, "rt");      else	{	  fp = stdin;	  setmode (0, O_TEXT);	}      if (fp == NULL)	{	  perror ("cygpath");	  exit (1);	}      setbuf (stdout, NULL);      while (fgets (buf, sizeof (buf), fp) != NULL)	{	  char *s = buf;	  char *p = strchr (s, '\n');	  if (p)	    *p = '\0';	  if (options_from_file_flag && *s == '-')	    {	      char c;	      for (c = *++s; c && !isspace (c); c = *++s)		switch (c)		  {		  case 'a':		    absolute_flag = 1;		    break;		  case 'i':		    ignore_flag = 1;		    break;		  case 's':		    shortname_flag = 1;		    longname_flag = 0;		    break;		  case 'l':		    shortname_flag = 0;		    longname_flag = 1;		    break;		  case 'm':		    unix_flag = 0;		    windows_flag = 1;		    mixed_flag = 1;		  case 'w':		    unix_flag = 0;		    windows_flag = 1;		    break;		  case 'u':		    windows_flag = 0;		    unix_flag = 1;		    break;		  case 'p':		    path_flag = 1;		    break;		  case 'D':		  case 'H':		  case 'P':		  case 'S':		  case 'W':		    output_flag = 1;		    o = c;		    break;		  }	      if (*s)		do		  s++;		while (*s && isspace (*s));	    }	  if (*s && !output_flag)	    doit (s);	  if (!*s && output_flag)	    dowin (o);	}    }  exit (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -